On Wed, Mar 9, 2011 at 8:15 AM, Mads Ipsen <madsip...@gmail.com> wrote:

>  Here is a script (below).
>
> I want the blue circle to appear as a circle with a 1:1 aspect ratio,
> making it look like a circle and not an ellipse. Just like the scale free
> circles making up the curve of the damped oscillationsn also shown in the
> plot.
>
> Preferably, the circle should also be scale free making it have the same
> size no-matter how much the plot has been zoomed.
>


You could use a big marker in a scatter plot; the default marker style is a
circle.  For example:

-----
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import CirclePolygon

x = np.arange(0, 10, 0.1)
y = np.exp(-x/2.) * np.sin(2*np.pi*x)

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x, y, 'ro-', zorder=0)
ax.set_xlim(0, 10)
ax.set_ylim(-1, 1)

# I want this circle to appear as a circle
##circle = CirclePolygon((7.5,0.0), radius=0.1, zorder=1)
##ax.add_patch(circle)
plt.scatter([7.5],[0.0], s=800, edgecolor='k', facecolor='b', alpha=0.5)

plt.show()

-----

Warren



>
> Best regards,
>
> Mads
>
> import numpy as np
> import matplotlib.pyplot as plt
> from matplotlib.patches import CirclePolygon
>
> x = np.arange(0, 10, 0.1)
> y = np.exp(-x/2.) * np.sin(2*np.pi*x)
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.plot(x, y, 'ro-', zorder=0)
> ax.set_xlim(0, 10)
> ax.set_ylim(-1, 1)
>
> # I want this circle to appear as a circle
> circle = CirclePolygon((7.5,0.0), radius=0.1, zorder=1)
> ax.add_patch(circle)
>
> plt.show()
>
>
>
> On 2011-03-09 15:00, Aman Thakral wrote:
>
> Could you provide some sample code that recreates the problem (and shows
> what you're trying to accomplish)?
>
> On Wed, Mar 9, 2011 at 8:58 AM, Mads Ipsen <madsip...@gmail.com> wrote:
>
>>  I tried that, but that will make the entire plot look very strange if
>> xlim = [0;100] and ylim=[-1:1].
>>
>> What I really want to do is add a scale free aspect ratio correct circle
>> to the plot. Just like the circles that appear on a scatter plot.
>>
>> Best regards,
>>
>> Mads
>>
>>
>> On 2011-03-09 14:44, Aman Thakral wrote:
>>
>> Hi Mads,
>>
>> Did you add axis='equal' to you axes command?
>>
>> e.g. ax = fig.add_subplot(111, aspect='equal')
>>
>>  -Aman
>>
>> On Wed, Mar 9, 2011 at 6:07 AM, Mads Ipsen <madsip...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I am using the Qt4 based back engine for displaying a 2D plot in a
>>> widget. The plot typically contains lots of line plots. Suppose I add a
>>> CirclePolygon to the plot like this:
>>>
>>> circle = CirclePolygon((x,y), radius=0.04, edgecolor='black',
>>> facecolor='red', zorder=1)
>>> axes.add_patch(circle)
>>>
>>> Then when I start to zoom in the window the aspect ratio of the circle
>>> is not preserved (it appears like an ellipse). If you plot a line with
>>> points, displaying its points using circles, these circles do have their
>>> aspect ratio (and size) preserved. There must be some approach for
>>> achieving the same effect for a manually added circle.
>>>
>>> Any help is appreciated,
>>>
>>> Best regards,
>>>
>>> Mads
>>>
>>> --
>>> +--------------------------------------------------------------+
>>> | Mads Ipsen, Scientific developer                             |
>>> +-------------------------------+------------------------------+
>>> | QuantumWise A/S               | phone:          +45-29716388 |
>>> | Lersø Parkallé 107            | www:     www.quantumwise.com |
>>> | DK-2100 Copenhagen Ø, Denmark | email:  mads.ip...@gmail.com |
>>> +-------------------------------+------------------------------+
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Colocation vs. Managed Hosting
>>> A question and answer guide to determining the best fit
>>> for your organization - today and in the future.
>>> http://p.sf.net/sfu/internap-sfd2d
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Matplotlib-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>
>>
>>  --
>> +--------------------------------------------------------------+
>> | Mads Ipsen, Scientific developer                             |
>> +-------------------------------+------------------------------+
>> | QuantumWise A/S               | phone:          +45-29716388 |
>> | Lersø Parkallé 107            | www:     www.quantumwise.com |
>> | DK-2100 Copenhagen Ø, Denmark | email:  mads.ip...@gmail.com |
>> +-------------------------------+------------------------------+
>>
>>
>>
>
> --
> +--------------------------------------------------------------+
> | Mads Ipsen, Scientific developer                             |
> +-------------------------------+------------------------------+
> | QuantumWise A/S               | phone:          +45-29716388 |
> | Lersø Parkallé 107            | www:     www.quantumwise.com |
> | DK-2100 Copenhagen Ø, Denmark | email:  mads.ip...@gmail.com |
> +-------------------------------+------------------------------+
>
>
>
>
> ------------------------------------------------------------------------------
> Colocation vs. Managed Hosting
> A question and answer guide to determining the best fit
> for your organization - today and in the future.
> http://p.sf.net/sfu/internap-sfd2d
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

<<attachment: image.png>>

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to