Reversed axis with range specified

Hello,

There is an example here of reversing an axis whilst also specifying a range. However, the range specification doesnā€™t work for me in a Jupyter notebook. Changing the maximum range to 15 for instance does not affect the plot.

Thanks

@MrWallace The autorange key can get only one of the following values: True, False or ā€˜reversedā€™ ( see https://plot.ly/python/reference/#layout-xaxis-autorange ).
An xaxis range greater then the real range of the x-values of your data points is displayed in a Plotly plot only when autorange=False.
But in this case you cannot reverse the xaxis, because autorange=False+ā€˜reversedā€™ doesnā€™t work.

If you really want a blank area at the left of your plot,
where to insert an annotation, for example,
then a solution is to add a trace consisting in only one invisible point, of x-coordinate=15:

additional_trace=go.Scatter(x=[15], y=[60], marker=dict(color='white'))
and replace in your code the line
data=[trace]
with
data=[trace, additional_trace]

Hi empet, thanks for your reply. Iā€™m sorry, I perhaps didnā€™t clarify what Iā€™d like to do.

Letā€™s say I have some data with a range in x from 0 to 10. I want to display this data on an x-axis which is reversed so 10 is on the left and 0 on the right. However, Iā€™d additionally like to display only a limited range of the whole data, letā€™s say from 5 to 8 (or 8 to 5, since itā€™s reversed). I have found that the code in the example I previously linked to does not do what I believe it is meant to be doing. Namely the range=[0, 10] in this code:

xaxis=dict(autorange='reversed', range=[0, 10])

in the example does not seem to have any effect on the plot. If autorange='reversed' is removed, then the range=[...] does have an effect.

In fact I can achieve what I want by simply omitting the autorange and specifying the range as range=[10,0]. So now Iā€™m wondering what is autorange=reversed meant to do that range=[max, min] canā€™t? Regarding your example, it seems we could achieve some blank space on the left of the reversed plot just by changing the range e.g. range=[max+5, min].

Thanks

2 Likes

The solution is described here: