matplotlib tripcolor:当我改变alpha参数时,网格正在显示

时间:2014-08-05 13:23:37

标签: matplotlib opacity alpha mesh

我试图改变tripcolor garph的不透明度。设置alpha参数是改变不透明度,但也显示网格网格。我认为这种情况正在发生,因为alpha参数也没有改变边缘的不透明度。我试着设置edgecolor =' none'但这不能解决我的问题。有没有办法在不显示网格的情况下更改不透明度?

"""
Pseudocolor plots of unstructured triangular grids.
"""
import matplotlib.pyplot as plt
import matplotlib.tri as tri
import numpy as np
import math

# Creating a Triangulation without specifying the triangles results in the
# Delaunay triangulation of the points.

# First create the x and y coordinates of the points.
n_angles = 36
n_radii = 8
min_radius = 0.25
radii = np.linspace(min_radius, 0.95, n_radii)

angles = np.linspace(0, 2*math.pi, n_angles, endpoint=False)
angles = np.repeat(angles[...,np.newaxis], n_radii, axis=1)
angles[:,1::2] += math.pi/n_angles

x = (radii*np.cos(angles)).flatten()
y = (radii*np.sin(angles)).flatten()
z = (np.cos(radii)*np.cos(angles*3.0)).flatten()

# Create the Triangulation; no triangles so Delaunay triangulation created.
triang = tri.Triangulation(x, y)

# Mask off unwanted triangles.
xmid = x[triang.triangles].mean(axis=1)
ymid = y[triang.triangles].mean(axis=1)
mask = np.where(xmid*xmid + ymid*ymid < min_radius*min_radius, 1, 0)
triang.set_mask(mask)

# Illustrate Gouraud shading.
plt.figure()
plt.gca().set_aspect('equal')
plt.tripcolor(triang, z, shading='gouraud', cmap=plt.cm.rainbow, alpha=0.5, edgecolor='none')
plt.colorbar()
plt.title('tripcolor of Delaunay triangulation, gouraud shading')

plt.show()

非常感谢你的时间,

多兰基尔托

1 个答案:

答案 0 :(得分:0)

你可以试试:&#34; edgecolors =&#39; k&#39;,linewidth = 0.0&#34;所以这可以将线宽设置为零,这使得该行失效