I have a region I'd like to hatch which borders on an existing plot line (of the same colour) that is dashed.
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()
In this example I'd want the diagonal line from 0,0 to 1,1 to be dashed.
Many thanks in advance.
>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()
Former answer
This seems to do the trick!
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With