Dav*_* M. 3 matplotlib python-3.x contourf
我想使用 Matplotlib v2.2.2 和该函数更改填充线的密度contourf()(具体来说,我想增加密度)。我读到,您可以通过增加使用剖面线图形的次数来增加剖面线的密度(例如替换x为xx)。然而,这种变化对我没有任何影响。我的后端是Qt5Agg,我使用的是Python v3.6.4。
微量元素:
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()
Run Code Online (Sandbox Code Playgroud)
产生输出
可能的重复:
这个问题有7年历史了,需要定义一个自定义类。这仍然是最好的选择吗?
这个问题基本上正是我要问的,但是MWE有点复杂,并且没有吸引任何答案。
Imp*_*est 10
一般情况下孵化的密一些是没有问题的。这确实是通过重复阴影图案来完成的。例如/,,,。/////
在这里,您有两个轮廓区域/级别。因此你需要两个舱口。
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=['/',None] )
ax2.contourf( X, Y, Z, [1,2], colors='none', hatches=['//',None] )
plt.show()
main()
Run Code Online (Sandbox Code Playgroud)