Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从Matplotlib中的轮廓线中删除线_Python_Matplotlib - Fatal编程技术网

Python 从Matplotlib中的轮廓线中删除线

Python 从Matplotlib中的轮廓线中删除线,python,matplotlib,Python,Matplotlib,我正在使用以下代码使用matplotlib中的contourf等高线绘制一些数据。我已经将色条的透明度设置为0.6,但是在每个颜色间隔之间都有一些我无法消除的恼人的线条。在contourf中似乎没有设置linestyle的方法,有什么想法吗 #instantiating and titiling the figure fig, ax1 = plt.subplots(figsize=(7,5)) fig.suptitle('Testing Simple Neural Networks', y=0.

我正在使用以下代码使用
matplotlib
中的
contourf
等高线绘制一些数据。我已经将色条的透明度设置为0.6,但是在每个颜色间隔之间都有一些我无法消除的恼人的线条。在
contourf
中似乎没有设置
linestyle
的方法,有什么想法吗

#instantiating and titiling the figure
fig, ax1 = plt.subplots(figsize=(7,5))
fig.suptitle('Testing Simple Neural Networks', y=0.96, fontsize=16, fontweight='bold');

#defining colour tables
cm = plt.cm.coolwarm

#plotting the contour plot
levels = np.linspace(0, 1, 25)
cont1 = ax1.contourf(p1_mesh, p2_mesh, y_mesh, levels=levels, cmap=cm, alpha=0.6, linewidths=10)

#plotting the entire dataset - training and test data. 
scat1 = ax1.scatter(X['p1'], 
                    X['p2'], 
                    c=y,
                    cmap=cm,
                    edgecolors='k');

#setting axis and legend
ax1.set(ylabel='p2',
        xlabel='p1',
        xlim=(0,255),
        ylim=(0,255));
ax1.legend(*scat1.legend_elements(), title='Target');
ax1.set_axisbelow(True)
ax1.grid(color='xkcd:light grey')
cbar = fig.colorbar(cont1)

您可以将选项
抗锯齿=True
添加到
ax1.tourtf
,它应该会修复它。

尝试从
ax1.tourtf()
中删除
线宽=10
。是的,我实际上把它作为一种检查,看看它是否对那些并不不幸的行产生了任何影响。正如我后来在中检查的,
线宽
线型
仅影响
轮廓
而非
轮廓