Asnap hlines and vlines to whole pixels in matplotlib
I want to draw some hlines and vlines snapped to occupy whole pixels on the screen, not spread across several pixels (rendered, antialiased) as usual. Is there a transform T() so t开发者_JAVA百科hat
vlines( T(x), T(ylo), T(yhi), linewidth=Twidth(.5) )
draws whole pixels ? Or, is there a way of telling some Mac backend (I use Qt4agg) to do this ?
Do you just want to turn antialiasing off?
For example:
import matplotlib.pyplot as plt
x = [1, 4, 7]
ylow = [0, 3, -2]
yhigh = [1, 4, 2]
width = [8, 15, 6]
plt.vlines(x, ylow, yhigh, linewidth=width,
antialiased=False)
plt.axis([0, 8, -4, 5])
plt.show()
精彩评论