Hello there,
I am trying to create a plot with multiple x-y axes. There is a “bar chart” and also a “line chart” at the same time. I just want to add the “same x-axis” to also the upside of the chart.
import plotly.graph_objects as go
fig = go.Figure(
data=[
go.Bar(name='Ranking Count', x=df_average[("count","rank")], y=df_average.index[:10], yaxis='y', xaxis="x", offsetgroup=1, orientation="h", text=df_average[("count","rank")]),
go.Scatter(name='Average Ranking', x=df_average[("mean","rank")], y=df_average.index[:10], yaxis='y2', xaxis="x2", orientation="h", text=df_average[("mean","rank")])
],
layout={
'yaxis': {'title': 'SERP Appearence Count'},
'yaxis2': {'title': 'Average Ranking', 'overlaying': 'y', 'side': 'right'},
"title": "Ranking Domains and Their General Situation",
"legend_title":"Legend",
"font":{"family":"Open-Sans","size":15,"color":"RebeccaPurple"}
},
)
# Change the bar mode
fig.update_layout(barmode='group', bargap=0.5, width=1000, height=500, legend=dict(
yanchor="top",
y=1.5,
xanchor="right",
x=1.3))
fig.show()