I’m using plotly graph_objects for the Figure Class. I’m creating a pareto chart, I have a question. I need to add points for each variable on the line. I looked at the documentation and I didn’t find something to approximate like px.line(markers=True)
This is my code that I’m using for data
trace2 = {
"line": {
"color": "rgb(255,7,7)",
"width": 2.5,
#'backoff':True
},
"name": "Pareto graph",
"type": "scatter",
"x": dataframe.index,
"y": dataframe['random'],
"yaxis": "y2",
}
This current graphic I put some circles to show the idea that I want to get a result
AIMPED
March 31, 2023, 2:45pm
2
Hi @sc0v1n0 welcome to the forums.
I think you are searching for mode='lines+markers'
https://plotly.com/python/line-and-scatter/
Extracted example:
import plotly.graph_objects as go
# Create random data with numpy
import numpy as np
np.random.seed(1)
N = 100
random_x = np.linspace(0, 1, N)
random_y0 = np.random.randn(N) + 5
random_y1 = np.random.randn(N)
random_y2 = np.random.randn(N) - 5
fig = go.Figure()
# Add traces
fig.add_trace(go.Scatter(x=random_x, y=random_y0,
mode='markers',
name='markers'))
fig.add_trace(go.Scatter(x=random_x, y=random_y1,
mode='lines+markers',
name='lines+markers'))
fig.add_trace(go.Scatter(x=random_x, y=random_y2,
mode='lines',
name='lines'))
fig.show()
2 Likes
Thanks, It turned out better than I thought.
bar_1 = Bar(
x=dataframe.index,
y= dataframe['random'],
name="random",
marker= {
"color": list(np.repeat('rgb(38,76,208)', 10) )+ list(np.repeat('rgb(50,205,50)', len(dataframe.index) - 10)),
}
)
scatter_1 = Scatter(
x=dataframe.index,
y=dataframe['random'],
line={
"color": "rgb(255,7,7)",
"width": 2.5,
'backoff':True,
},
yaxis= "y2",
name= "Pareto",
mode='lines+markers'
)
1 Like