X axis range with time series scatter plot - different behavior lines vs markers

Hi
I am plotting two time series traces on a scatter. One has a mode of “lines”, the other “lines+markers”. With both traces displayed the range of the axis extends beyond the range of the data - leaving a gap between the y and y2 axis and the first/last data points. If I remove the trace with a mode “lines+markers” this gap dissapears - the first datapoint in the series is right up against the y axis, and the last right against y2. This is my favored behavior - but how do I achieve this when I have a trace with “lines+markers” or even just “markers” (has same effect)?
Thanks

Hey @danoharding - could you share the graph with a URL? That’d be a huge help, thanks!

Hi @chriddyp - thanks for offering to help! Here you go…

https://plot.ly/~danoharding/3/wind-speed-kt-vs-time/?share_key=CdG3zP4cHJafV6LpsXqBrt

Hello,

I was wondering if there was a fix for this issue? I am having the same problem, which is especially troubling when using the range slider, and range selector buttons to show various parts of the time series. I have knocked up some generic code based of off some of your examples that shows this behavior and can share that.

Best.

This is the intended behaviour.

By default, plotly.js expands the axes to give enough breathing for the markers points present of the graph. We don’t expands the axes when only lines segments are present.

To override the default, simply set layout.xaxis.range to the range you want to set at all times.

See example: http://codepen.io/etpinard/pen/BKeyrw

Hi is there any way this default behavior could be disabled ? especially for rangeslider !!
You said settings the xaxis.range, unfortunately this is not possible with range sliders:

Here’s how: https://codepen.io/etpinard/pen/wPRYgR?editors=0010

Any solution for this behaviour , I’m facing the same problem.


I also had this issue when plotting using a np.datetime object. Turns out the solution comes from this sentence:

The data range can be set manually using either datetime.datetime objects, or date strings.

Found here: Time Series

This was quite difficult to find, since on the same page above (on the top), it says:

Plotly auto-sets the axis type to a date format when the corresponding data are either ISO-formatted date strings or if they're a date pandas column or datetime NumPy array.

So, I’d expect the range would also work with those objects. So, suggestion for Plotly developers: please, also accept date ranges in the same formats and you accept the axis itself.