I would like to read out the default x-ticks values.
In below example, I would like to get the default array [1,3,5,7,9,11]
.
I do not care about how plotly calculates it, but only want to get the final x-ticks array.
import plotly.graph_objects as go
import pandas as pd
import plotly.express as px
import json
def save_fig(fig,pngname):
fig.write_image(pngname,format="png",width=800,height=500, scale=1)
print("[[%s]]"%pngname)
return
def main():
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
y = [28.8, 28.5, 37, 56.8, 69.7, 79.7, 78.5, 77.8, 74.1, 62.6, 45.3, 39.9]
fig = go.Figure(go.Scatter(x=x, y=y))
fig.update_layout(
xaxis=dict(
tickmode='linear',
tick0=1,
dtick=2
)
)
save_fig(fig,"/media/sf_work/demo.png")
return
main()
Output:
1