本文介绍了matplotlib 孵化fill_between 没有边缘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个想要填充的区域,该区域位于虚线的现有绘图线(相同颜色)的边界上.

I have a region I'd like to hatch which borders on an existing plot line (of the same colour) that is dashed.

但是,当我使用 fill_between 时,要阴影的区域周围也绘制了边框.此边框似乎与创建影线的线条共享属性,因此我无法将边缘颜色设置为无"或将线型设置为--",因为影线也受到类似影响.

However, when I use fill_between the region to be hatched has a border drawn around it also. This border seems share properties with the lines that create the hatching so I cannot set edgecolour to "none" or set linestyle as "--" as the hatching is similarly affected.

import matplotlib.pyploy as plt
plt.plot([0,1],[0,1],ls="--",c="b")
plt.fill_between([0,1],[0,1],color="none",hatch="X",edgecolor="b")
plt.show()

在这个例子中,我希望从 0,0 到 1,1 的对角线是虚线.

In this example I'd want the diagonal line from 0,0 to 1,1 to be dashed.

非常感谢.

推荐答案

> 2.0.1更新正如@CatherineHolloway所评论的那样,您需要使用 facecolor 而不是颜色:

>2.0.1 Update As commented by @CatherineHolloway you need to use facecolor instead of color now:

import matplotlib.pyplot as plt
plt.plot([0,1],[0,1],ls="--",c="b")
plt.fill_between([0,1],[0,1], facecolor="none", hatch="X", edgecolor="b", linewidth=0.0)
plt.show()

以前的答案

这似乎可以解决问题!

import matplotlib.pyplot as plt
plt.plot([0,1],[0,1],ls="--",c="b")
plt.fill_between([0,1],[0,1], color="none", hatch="X", edgecolor="b", linewidth=0.0)
plt.show()

这篇关于matplotlib 孵化fill_between 没有边缘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 20:51