[R] Drawing a circle on an existing graph.

Allan Kamau kamauallan at gmail.com
Sat Mar 12 21:07:40 CET 2011


On Sat, Mar 12, 2011 at 10:22 PM, David Winsemius
<dwinsemius at comcast.net> wrote:
>
> On Mar 12, 2011, at 10:56 AM, Allan Kamau wrote:
>
>>> --- On Sat, 3/12/11, Allan Kamau <kamauallan at gmail.com> wrote:
>>>
>>>> From: Allan Kamau <kamauallan at gmail.com>
>>>> Subject: [R] Drawing a circle on an existing graph.
>>>> To: r-help at r-project.org
>>>> Received: Saturday, March 12, 2011, 3:08 AM
>>>> I would like to draw a circle on a
>>>> graph I am plotting in R and use
>>>> the current plot's coordinate system.
>>>> The most basic functionality I am looking for is the
>>>> ability to plot a
>>>> circle on an already existing graph by simply providing the
>>>> xy
>>>> coordinates for it's centre and the radius.
>>>>
>>>> I am also looking for a way to obtain x,y values of a point
>>>> (of a
>>>> circle) by specifying only the origin x,y the angle and
>>>> radius.
>>>>
>>>> Please point me so such a library and perhaps some simple
>>>> one line code.
>>>>
>>>> Allan.
>>>>
>> On Sat, Mar 12, 2011 at 5:28 PM, John Kane <jrkrideau at yahoo.ca> wrote:
>>>
>>> Is this of any use?
>>> http://tolstoy.newcastle.edu.au/R/help/06/04/25821.html
>>>
>>
>> Thank you John, that is what I was looking for.
>> The code does draw a neat circle that is not stretched. After plotting
>> the circle on an existing plot I notice that the original plot was
>> indeed stretched somehow by approximately some 1:1.1 ratio (I think).
>> Now I am looking for a way to enforce none stretching in my original
>> graph.
>
> `plot.window` has an `asp` argument that is useful for that purpose. Most
> plotting with base graphics will pass an asp=1 argument along as part of the
> `...` arguments,
>
> --
>
> David Winsemius, MD
> West Hartford, CT
>
>
Thank you David, asp=1 argument in my plot function brought about 1:1
aspect ratio to the graph and now the circle sits very neatly within
it. All is well.
John is there another version of your circle drawing code that accepts
values in accordance with the current plot's scale units in place of
the current real distance measurement (inches) units.

Allan.



More information about the R-help mailing list