Error nulling error in matplotlib template?

The error is described here:

Matplotlib error pane not marker oriented

and here: https://github.com/matplotlib/matplotlib/issues/3400

Basically, markers are lagged by 1 pixel all the time .. You can even see this on the Matplotlib tutorial's own page if you take a close look at the second plot: http://matplotlib.org/1.2.1/examples/pylab_examples/errorbar_demo.html

This is very frustrating as I cannot generate post quality plots from matplotlib and I am very surprised it has not been fixed.

Anyway, I have too much time and code nested in matplotlib to switch to another package. So my question is, how are you going to do the workaround? I suppose one solution is to overlay markers 1 pixel left / right from errors. I do not know how to do that. I figured out how to get the display coordinates of my plot points, but how can I make an interactive plot that keeps 1 pixel offset? I can plot them with 1pixel offset, but then you cannot magnify or manipulate the plot.

+3


source to share


1 answer


The Matplotlib command seems to have fixed the problem when calling savefig () using .svg or .pdf, but for .png I suggest that you can work around this problem by using an odd number for the error line width. Using the first example in the Matplotlib Tutorial , if we use

plt.errorbar(x, y, yerr=0.4, marker='X', markersize=15)

      

then the bars are shifted like this:

enter image description here

However, if we use a line width of 3



plt.errorbar(x, y, yerr=0.4, marker='X', markersize=15, elinewidth=3)

      

then the bars are centered like this:

enter image description here

It's not ideal, but it gets the job done if you don't mind having a few thicker lines.

+2


source







All Articles