Add edgecolor parameter

Allow user to set the polygons edge color.
This commit is contained in:
Etienne Dumur 2020-06-28 14:50:44 +02:00
parent d32d61a1e2
commit 919ee54b59
2 changed files with 15 additions and 4 deletions

View File

@ -33,7 +33,9 @@ y = np.tile(np.arange(1, yn+1), xn).reshape(xn, yn)
z = np.exp(-(x*xn)**2/1000)[:-1,:-1]
## Create image item
pcmi = pg.PColorMeshItem()
edgecolors = None
# edgecolors = {'color':'w', 'width':2} # May be uncommened to see edgecolor effect
pcmi = pg.PColorMeshItem(edgecolors=edgecolors)
view.addItem(pcmi)

View File

@ -31,7 +31,7 @@ class PColorMeshItem(GraphicsObject):
def __init__(self, x=None, y=None, z=None,
cmap='viridis'):
cmap='viridis', edgecolors=None):
"""
@ -44,8 +44,13 @@ class PColorMeshItem(GraphicsObject):
colors.
cmap : str, default 'viridis
Colormap used to map the z value to colors.
edgecolors : dict , default None
The color of the edges of the polygons.
Default None means no edges.
The dict may contains any arguments accepted by :func:`mkColor() <pyqtgraph.mkColor>.
Example:
mkPen(color='w', width=2)
"""
GraphicsObject.__init__(self)
self.x = x
@ -56,6 +61,7 @@ class PColorMeshItem(GraphicsObject):
self.axisOrder = getConfigOption('imageAxisOrder')
self.edgecolors = edgecolors
if cmap in Gradients.keys():
self.cmap = cmap
else:
@ -84,7 +90,10 @@ class PColorMeshItem(GraphicsObject):
p = QtGui.QPainter(self.qpicture)
# We set the pen of all polygons once
p.setPen(QtGui.QColor(0, 0, 0, 0))
if self.edgecolors is None:
p.setPen(QtGui.QColor(0, 0, 0, 0))
else:
p.setPen(fn.mkPen(self.edgecolors))
## Prepare colormap
# First we get the LookupTable