All works as expected except for the x axis labels. The x axis labels are one day ahead of what the actual data set shows. In other words, the actual date values in the data start at Feb 8, 15, 22, 29 then March 7 & 14. Any idea why the visual is starting at Feb 9 instead of Feb 8?
Code:
import numpy as np
import pandas as pd
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import plotly.express as px
Could you please paste here the contents of sd.Week in the subplot, row=1, col=1, or eventually to upload somewhere a csv file with data similar to yours, to be able to reproduce the hypothetical issue?
Hi @Troy,
You get displayed different days than those provided in your data frame, sd for example, because Plotly identified that your data are weekly data and by default each week is represented by its Sunday.
Your data for San Diego have been recorded each Saturday.
To set as xaxis ticklabels the data provided in your DataFrame you can use xaxis_tickvals, and xaxis_ticktext.
The former is the list of dates for ticklabel positions, while the latter is the list of ticklabels you want to be displayed:
Yes! That fixed the issue. Thank you @empet for your help. Are you aware of any reason why I would be unable to customize the bar width when my x axis is datetime? Without adding the āwidthā parameter the graph displays perfectly, Iād just like to make the bars skinnier. Adding in the āwidthā parameter (code below) causes the Bar chart to be completely emptyā¦no bars at all. Am I missing something?
When we represent date on xaxis, the bar width is measured in miliseconds. 1day = 86400000 milliseconds. width = 4*86400000means a width of 4 days. Just try it, and if you donāt like the bar thickness decrease it to width=3*86400000, etc
Update: when you want bars of the same width set just width=number not list!!!