如何在 matplotlib 中分离阴影和边缘颜色? [英] How to decouple hatch and edge color in matplotlib?

查看:37
本文介绍了如何在 matplotlib 中分离阴影和边缘颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 matplotlib 中绘制一个条形,白色为填充色,红色为填充色,黑色为边缘色.但是,看起来边缘颜色也会改变剖面线的颜色.所以,我无法将边缘和阴影的颜色分离.你有什么建议吗?谢谢.

I would like to draw a bar in matplotlib with white as fill color, red as hatch color and black as edge color. However, it looks like the edge color changes also the color of hatch. So, I am not able to decouple the color of edges and hatch. Do you have any suggestion? Thanks.

推荐答案

绘制条形图两次:

import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse, Polygon

fig = plt.figure()
ax1 = fig.add_subplot(111)
# draw hatch
ax1.bar(range(1, 5), range(1, 5), color='none', edgecolor='red', hatch="/", lw=1., zorder = 0)
# draw edge
ax1.bar(range(1, 5), range(1, 5), color='none', edgecolor='k', zorder=1, lw=2.)

ax1.set_xticks([1.5, 2.5, 3.5, 4.5])
plt.show()

这篇关于如何在 matplotlib 中分离阴影和边缘颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆