I'm not 100% sure what you want to move where, but it sounds like you'd like the dates to the right there to pop up in the middle of the chart between the facets. In the structure of the figure, those are annotations. And you can put them anywhere you'd like, but how and where will depend on the structure of your particular figure. Since you haven't provided a dataset, I'll show you some general principals using an example from the plotly epress docs that should help you out. If you provide a dataset and fully working code, I'll be able to help you with the details.
Plot 1:
Code 1:
import plotly.express as px
df = px.data.tips()
fig = px.scatter(df, x="total_bill", y="tip", facet_row="time", facet_col="day", color="smoker", trendline="ols",
category_orders={"day": ["Thur", "Fri", "Sat", "Sun"], "time": ["Lunch", "Dinner"]})
fig.show()
Here, the elements corresponding to the ones you'd like to move are 'time=Lunch'
and 'time=Dinner'
. So in this case, the elements can be placed wherever you'd like along the x-axis like this:
Code: 2
for i, a in enumerate(fig['layout']['annotations']):
if a['text'][:4]=='time':
a['x']=0.475
a['font']=dict(size = 10, color='rgba(255,0,200,0.8)')
print(a)
fig.show()
Plot: 2
I know this is a bit hacky approach, but I hope you'll find it useful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.