@krisvija wrote:
import plotly.express as px df = px.data.iris() fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species") fig.show()
If I want to write the same code in plotly.graph_objects , than how I can include the color argument without using for loop. Basically I want to use bar and line chart in same axis with bar having a color code based on a different variable and pass that as a return in Dash.
bars = [] for label, label_df in df.groupby('label'): bars.append(go.Bar(x=label_df.x, y=label_df.y, name=label, marker={'color': colors[label]})) trace1 = bars # trace2 = go.Scatter(x=label_df.x, y=label_df.y, name='Nifty 50', mode='lines+markers') fig = go.Figure(data=[trace1]) fig.show()
Posts: 2
Participants: 2