hello guys i was trying in the past few days to learn plotly.py and i try to make plots i found on the internet with plotly one of these plots was this one
https://journals.plos.org/ploscompbiol/article/figure?id=10.1371/journal.pcbi.1003833.g004
my code trying to copy it
draft_template = go.layout.Template()
x = np.linspace(-np.pi, np.pi, 300)
fig=go.Figure()
fig.update_layout(template=draft_template
,showlegend=True
,xaxis=go.layout.XAxis(
range=[-np.pi-0.3, np.pi+0.3],
tickvals=[-np.pi,-np.pi/2, np.pi/2, np.pi],
ticktext=['$-\pi$', '$-\pi/2$', '$+\pi/2$', '$+\pi$'],
showgrid=False)
,yaxis=go.layout.YAxis(
range=[-1.11, 1.11],
tickvals=[-1, 0, 1],
ticktext=['$-1$', '$0$', '$1$'],
showgrid=False)
,legend=dict(x=.1, y=1
,itemsizing='constant'))
fig.add_trace(go.Scatter(x=x
,y=np.sin(x)
,name='<b>sin</b>'
,line=dict(color='red', width=4)))
fig.add_trace(go.Scatter(x=x
,y=np.cos(x)
,name='<b>cosine</b>'
,line=dict(color='blue', width=4)))
fig.show()
i have a few problems with this one
-
i try to make xaxis and yaxis tick text in the middle
-
when i use <\b>β to make tick text bold it doesnβt work for some reason
-
i canβt change the arrow properties like i can do in matplotlib
https://jakevdp.github.io/PythonDataScienceHandbook/04.09-text-and-annotation.htm
- the red line become a blue after it went under zero how can i do this in plotly
and last sorry for my bad English