2 Jul 01:19
Plotting filled circles
I'm a new user of matplotlib (athough I have been using both Matlab and
Python for years).
I have an application where I need to display data as a set of filled
circles. The centre and the radius of the circles are both specified in
data coordinates. The data points have an additional scalar attribute,
which is displayed using a pseudo-colour mapping.
I've hacked something together where the circles are approximated by
polygons using either the axis fill method or the pylab fill function. I
select the colour by calling the get_rgba method of a ScalarMappable
object. In the following code snippet c is a tuple containg the x and y
coords of the centre of the circle, the radius, and a scalar "value"
theta = arange(numSegs+1) * 2.0 * math.pi / numSegs
cos_theta = cos(theta)
sin_theta = sin(theta)
for c in cart:
x = c[1] + c[3] * cos_theta
y = c[2] + c[3] * sin_theta
v = c[4]
fill(x, y, facecolor=mapper.to_rgba(v), linewidth=0.5)
It all works. However, I saw in the API documentation (and the source)
that there is a Circle object in patch. I was hoping that using this
rather than polygons would give better quality output and possibly
smaller files. Now I can instantiate it
circle = Circle((x,y), c[3], facecolor=cmapper.to_rgba(v))
(Continue reading)
.
- Andrew
Stephen George wrote:
> It *seems* like it already does what you are trying to do?, maybe I'm
> missing something in my understanding.
>
> Steve
>
>
>
> Andrew McLean wrote:
>> I'm a new user of matplotlib (athough I have been using both Matlab and
>> Python for years).
>>
>> I have an application where I need to display data as a set of filled
>> circles. The centre and the radius of the circles are both specified in
>> data coordinates. The data points have an additional scalar attribute,
>> which is displayed using a pseudo-colour mapping.
>>
>> I've hacked something together where the circles are approximated by
>> polygons using either the axis fill method or the pylab fill function. I
RSS Feed