Edges for wedges problem

I am using matplotlib version 1.3.1 with numpy 1.7.1 on a win32 platform for the following code:

import matplotlib
import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection
import matplotlib.colors as col
import matplotlib.cm as cm
from matplotlib.patches import Wedge
import numpy as np

def register_cmap(cmapName):
     """
      Purpose: define colormap using the from_List() method as a
               segmented list and register it.
     """
     startcolor = '#00AF33' # truegreen
     midcolor = '#FFE600' # yolk (a medium dark yellow)
     endcolor = '#FF0033' # bright red
     cmap2 = col.LinearSegmentedColormap.from_list(cmapName,
[startcolor,midcolor,endcolor])
     cm.register_cmap(cmap=cmap2)
     return cmap2

# Define my colormap red->yellow->green for curvature
my_cmap = register_cmap('reylgr')

# Modified matplotlib gallery example
radii = np.arange(0.0,1.05,.05) # inner radius of rings
width = 0.05 # width of rings
patches = []
for r in radii:
     wedge = Wedge((0.0,0.0), r+width, 0.0,360.0, width = width)
     patches.append(wedge)

fig = plt.figure()
ax = fig.add_subplot(111)

colors = radii
p = PatchCollection(patches, cmap=my_cmap)
p.set_array(colors)
ax.add_collection(p)
ax.set_xlim(-1.5,+1.5)
ax.set_ylim(-1.5,+1.5)
plt.colorbar(p)

plt.show()

When I execute this code I do get concentric circles (wedge rings) as expected. However,
I do not want "edges" along the boundaries of the rings. I would like the color changes
between rings to look like the colorbar.

I have tried several options with Wedge (e.g. edgecolor = "none"); but, this had no observable effect.

Help on this would be appreciated.

Hi,

add linewidths=0 (or edgecolor=‘none’, will do the same) to p = PatchCollection(patches, cmap=my_cmap)

note that PatchCollections can either get their properties from the original patch you create (the wedge) via the option match_original which defaults to false.

Shahar

···

On Jul 5, 2014, at 6:27 PM, Virgil Stokes <vs@…4551…50…> wrote:

I am using matplotlib version 1.3.1 with numpy 1.7.1 on a win32 platform for the
following code:

import matplotlib
import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection
import matplotlib.colors as col
import matplotlib.cm as cm
from matplotlib.patches import Wedge
import numpy as np

def register_cmap(cmapName):
“”"
Purpose: define colormap using the from_List() method as a
segmented list and register it.
“”"
startcolor = ‘#00AF33’ # truegreen
midcolor = ‘#FFE600’ # yolk (a medium dark yellow)
endcolor = ‘#FF0033’ # bright red
cmap2 = col.LinearSegmentedColormap.from_list(cmapName,
[startcolor,midcolor,endcolor])
cm.register_cmap(cmap=cmap2)
return cmap2

Define my colormap red->yellow->green for curvature

my_cmap = register_cmap(‘reylgr’)

Modified matplotlib gallery example

radii = np.arange(0.0,1.05,.05) # inner radius of rings
width = 0.05 # width of rings
patches = []
for r in radii:
wedge = Wedge((0.0,0.0), r+width, 0.0,360.0, width = width)
patches.append(wedge)

fig = plt.figure()
ax = fig.add_subplot(111)

colors = radii
p = PatchCollection(patches, cmap=my_cmap)
p.set_array(colors)
ax.add_collection§
ax.set_xlim(-1.5,+1.5)
ax.set_ylim(-1.5,+1.5)
plt.colorbar§

plt.show()

When I execute this code I do get concentric circles (wedge rings) as expected.
However,
I do not want “edges” along the boundaries of the rings. I would like the color
changes
between rings to look like the colorbar.

I have tried several options with Wedge (e.g. edgecolor = “none”); but, this had
no observable effect.

Help on this would be appreciated.


Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users