Black Lives Matter. Please consider donating to Black Girls Code today.

Line clipping on reversed axes

I am plotting a change in ranking over periods, so it makes sense to use a reversed axis. However I find when I plot the line it gets clipped at rank number 1. I thought that cliponaxis might be a suitable workaround, or that i could use padding, but none seem to work.

Any ideas on how I can get it to display the full line width when it lies on the axis?

data = {‘rank’: [2,2,2,2,1,1,2,2,2],
‘period’: [‘A’,‘B’,‘C’,‘D’,‘F’,‘G’,‘H’,‘I’,‘J’]}

rank = pd.DataFrame(data)

range = 15

trace1 = go.Scatter(x = rank[‘period’], y = rank[‘rank’])
data = [trace1]

layout = dict(title = ‘Clipping’,
xaxis = dict(showgrid= False,
ticks = ‘outside’,
tickcolor = ‘#acadaf’,
hoverformat = ‘.0f’),
yaxis = dict(showgrid = False,
zeroline = True,
showline = False,
ticks = ‘’,
tickcolor = ‘#acadaf’,
range= [15,1],
tick0= 1,
dtick= 1,
hoverformat = ‘.2f’),
showlegend= False

fig = go.Figure(data=data,layout=layout)
iplot(fig, filename=‘clipping example’)

Change the range and zeroline values in the yaxis dict, as follows:

range= [15, 0.5],

and you’ll get the right plot.

That worked! Thanks so much for your prompt reply, and your help. Much appreciated