matplotlib 中透明的axes.axhline?
我试图在轴上添加一条水平线来标记重要的 y 值,因此我使用:
fig = Figure(figsize=(5, 5))
ax = fig.add_axes((0.2, 0.2, 0.6, 0.6))
ax.plot(...)
ax.axhline(100000, xmin=0, xmax=1, linewidth=0.3, color=(0, 0, 0, 0.75))
canvas = FigureCanvasAgg(fig)
canvas.print_figure("chart.pdf", dpi=300)
但是我遇到了一些问题:
- 线宽的单位是什么?点?
- 该线似乎不尊重我的颜色中的 alpha 值。当
a = 0
时是透明的,当a > 0时是不透明的。 0
,没有半透明。这是一个错误还是我做错了什么?
我正在使用:
Mac OSX 10.6.7、Python 2.7、matplotlib 1.0.1、numpy 1.5.1
I'm trying to add a horizontal line to my axes to mark an important y
value, so I'm using:
fig = Figure(figsize=(5, 5))
ax = fig.add_axes((0.2, 0.2, 0.6, 0.6))
ax.plot(...)
ax.axhline(100000, xmin=0, xmax=1, linewidth=0.3, color=(0, 0, 0, 0.75))
canvas = FigureCanvasAgg(fig)
canvas.print_figure("chart.pdf", dpi=300)
However I've got a few problems:
- What unit is the linewidth? points?
- The line doesn't seem to respect the alpha value in my colour. It's transparent when
a = 0
and opaque whena > 0
, there's no semi-transparency. Is this a bug or am I doing something wrong?
I'm using:
Mac OSX 10.6.7, Python 2.7, matplotlib 1.0.1, numpy 1.5.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
线宽以磅为单位。
使用 matplotlib 1.0+ 时透明度对我来说效果很好。这是我用来测试的代码:
您试图在什么绘图上绘制 axhline ?也许与特定类型的情节有冲突。
Linewidth is in points.
The transparency works fine for me using matplotlib 1.0+. Here is the code I used to test:
What is the plot you are trying to draw an
axhline
over? Maybe there is a conflict with a particular type of plot.