开发者

Asnap hlines and vlines to whole pixels in matplotlib

开发者 https://www.devze.com 2023-04-03 00:30 出处:网络
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.

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()

Asnap hlines and vlines to whole pixels in matplotlib

0

精彩评论

暂无评论...
验证码 换一张
取 消