Ok have searched this forum, read on the internet and stackoverf…
I am new to all of this with plotly and python/pandas in general so please understand that I just a hobbyist.
What I would like to show are all the x axis labels for dates. Now there are just a few.
My “code” looks like this -
#-------------------------------------------------------------start
fig = go.Figure()
# Add traces
fig.add_trace(go.Scatter(x=FinDF['Report_Date_as_YYYY-MM-DD'], y=FinDF['Changes1'],
mode='lines',
name='Item1'))
fig.add_trace(go.Scatter(x=FinDF['Report_Date_as_YYYY-MM-DD'], y=FinDF['Changes2'],
mode='lines',
name='Item2))
fig.add_trace(go.Scatter(x=FinDF['Report_Date_as_YYYY-MM-DD'], y=FinDF['Changes3'],
mode='lines',
name='Item3'))
fig.update_layout(title="Diff",
xaxis_title="Date",
yaxis_title="Data",
font=dict(family="Courier New, monospace",size=12,color="#000"))
#xaxis=dict(tickformat='%b %d,%Y',tickmode='linear')
fig.update_xaxes(tickangle=90, tickformat='%Y-%m-%d',tickmode='linear')
fig.write_image("images/changes.png", width=1280, height=720)
#--------------------------------------------------------------end
The dataFrame column of FinDF[‘Report_Date_as_YYYY-MM-DD’] contains dates in format as 2020-01-01
What am I doing wrong?
With linear it looks like it only ads +1 in date instead of actually adding the corresponding dates in column of dataframe.
I also tried
fig.update_layout(xaxis_type='category')
and this works - however the dates and chart is mirrored. Which is obvious now when I think of it since the first record is the latest data. How to fix it?
0 2020-06-30
1 2020-06-23
2 2020-06-16
3 2020-06-09
4 2020-06-02
5 2020-05-26
6 2020-05-19
7 2020-05-12
8 2020-05-05
9 2020-04-28
10 2020-04-21
11 2020-04-14
12 2020-04-07
13 2020-03-31
14 2020-03-24
15 2020-03-17
16 2020-03-10
17 2020-03-03
18 2020-02-25
19 2020-02-18
20 2020-02-11
21 2020-02-04
22 2020-01-28
23 2020-01-21
24 2020-01-14
25 2020-01-07
Name: Report_Date_as_YYYY-MM-DD, dtype: object