I want to change the density of hatch lines using Matplotlib v2.2.2 and the contourf()
function (specifically, I want to increase the density). I have read that you can increase the density of a hatch by increasing how many times you use the hatch figure (e.g. replace x
with xx
). However, that change is having no effect for me. My backend is Qt5Agg
, and I'm using Python v3.6.4.
MWE:
import matplotlib.pyplot as plt
import numpy as np
def main():
x = np.arange( 0, 1.01, 0.01 )
X, Y = np.meshgrid( x, x )
Z = X + Y
fig, (ax1, ax2) = plt.subplots( 1, 2 )
ax1.contourf( X, Y, Z, [1,2], colors='none', hatches='x' )
ax2.contourf( X, Y, Z, [1,2], colors='none', hatches='xx' )
plt.show()
main()
which produces the output
Possible Duplicates:
This question is 7 years old and requires defining a custom class. Is this still the best option?
This question is basically exactly what I'm asking, but the MWE was a bit complicated, and didn't attract any answers.