plotly.js
plotly.js copied to clipboard
cannot change start of week day
How can I change start week day on a graph? Now I have only Sundays on xaxis. I need to display only Mondays on xaxis. Thank you. My plotly config is :
xaxis: {
type: 'date',
automargin: true,
tickformat: '%d.%m',
maxPadding: 1,
},
yaxis: {
tickmode: 'array',
automargin: true,
showticklabels: false,
showgrid: false,
},
@VladimirKondratenko Have you tried tickmode: "linear" and setting tick0 to desired time?
Hi @archmoj , the solution you proposed doesn't work well. When zooming in / out a chart the x axis changes between different time frequencies. It could be weeks (Sundays) in default zoom but months if you zoom out and all days if you zoom in. If you "hardcode" the ticks you'd always see only weeks.
Maybe your chart axis displays months by default but you want to see Mondays if you zoom in a bit. I know you can specify the format for any zoom level. But that doesn't sound like something you wan to do if the only change you need is to display Mondays instead of Sundays
@jankislinger the problem is just with month and year ticks - hard-coding a Monday as tick0 will be fine for day ticks and smaller, but for month and year you'd need to find a January 1 that's a Monday, and if you care about decade and century ticks you'd need a January 1 xx00 that's a Monday. Doable, but very awkward.
So yeah, I think this is worth reopening - adding some way to specify the canonical weekday, that only gets used for autoticks with a period of 1 or 2 weeks.
This probably isn't something Plotly staff will be able to work on in the near term unless someone is interested in sponsoring the work, but we'd happily accept a PR and help get it merged.
Thanks for quick response. Here's an example which does not automatically change ticks.
var trace1 = {
x:['2022-01-01', '2022-01-30'],
y: [0, 1],
type: 'scatter'
};
var data = [trace1];
var layout = {
xaxis: {
tickmode: "linear",
tick0: "2022-01-03",
dtick: 7 * 24 * 3600 * 1000
}
};
Plotly.newPlot('myDiv', data, layout, {scrollZoom: true});
| default | zoomed out | zoomed in |
|---|---|---|
![]() |
![]() |
![]() |
If I remove the dtick parameter the plot shows ticks by days regardless zoom


