I am looking to develop a graph with two x-axes labels of type pandas._libs.tslibs.timestamps.Timestamp
. The first will have monthly labels and the second will have quarterly labels (in different colors). However, I cannot get two different axes labels to show up with type Timestamp
. Below is a working example for type int.
WORKING - Plotly Graph with 2 x-axis labels of type int
import plotly.graph_objects as go
fig = go.Figure(data=None, layout=None)
fig.add_trace(
go.Scatter(
x=[1,2,3],
y=[4,5,6],
xaxis='x1',
mode="lines",
)
)
fig.add_trace(
go.Scatter(
x=[1,2,3],
y=[4,5,6],
xaxis='x2',
mode="lines",
)
)
layout=dict(
yaxis=dict(title='yaxis title'),
xaxis=dict(
overlaying= 'x',
tickmode= 'linear',
tick0= 1.1,
dtick= 1,
side= 'bottom',
color='blue'
),
xaxis2=dict(
overlaying= 'x',
tickmode= 'linear',
tick0= 1,
dtick= 1,
side= 'bottom',
color='red'
),
)
fig.layout=layout
fig.show()
NOT WORKING - Plotly Graph with 2 x-axis labels of type pandas._libs.tslibs.timestamps.Timestamp
Note: this is an incomplete code sample. If I can provide more information on the inputs, please let me know.
import plotly.graph_objects as go
fig = go.Figure(data=None, layout=None)
#x is a pandas series of type "pandas._libs.tslibs.timestamps.Timestamp"
#y is a pandas series of type "numpy.float64"
#add price plot
fig.add_trace(
go.Scatter(
x=x,
y=y,
xaxis='x1',
mode="lines"
),
row=1, col=1 #there are subplots in the graph
)
#add price plot
fig.add_trace(
go.Scatter(
x=x,
y=y,
xaxis='x2',
mode="lines"
),
row=1, col=1 #there are subplots in the graph
)
layout=dict(
yaxis=dict(title='yaxis title'),
xaxis = dict(
overlaying='x',
tickmode='linear',
tick0=days[30],
dtick="M3",
side='bottom',
color='red'
),
xaxis2 = dict(
overlaying='x',
tickmode='linear',
tick0=days[30],
dtick="M1",
side='bottom',
color='blue'
)
)
fig.layout=layout
fig.show()
Here are the two most useful links so far:
Any help is greatly appreciated! I have been stuck on this for a week.