I am using matplotlib in Python to plot a line with errorbars as follows:
plt.errorbar(xvalues, up_densities, yerr=ctl_sds, fmt='-^', lw=1.2, markersize=markersize,
markeredgecolor=up_color, color=up_color, label="My label", clip_on=False)
plt.xticks(xvalues)
I set the ticks on the x-axis using “xticks”. However, the error bars of the last point in xvalues (i.e. xvalues[-1]) are clipped on the right — meaning only half an error bar appears. This is true even with the clip_on=False option. How can I fix this, so that the error bars appear in full, even though their right side is technically outside xvalues[-1]?
thanks.
In matplotlib, most of the detailed control needs to be done through the Artists. I think this should do what you want:
The problem you were having is that the
clip_onkeyword was being used to control the markers and not the error bars. To control the errorbars,plt.errorbarreturns a tuple, where the second item is a list of errorbars. So here I go through the list and turn the clipping off for each errorbar.