plot circles where z values are circles radius

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

plot circles where z values are circles radius

Dr. Alireza Zolfaghari
Hi there,
I am trying to plot z values using Circle symbol. Each x and y has a value
which will be plotted using a circle where circle's radius is corrlated
with the value of z.

I wrote the code , but unable to change the size of circle no matter what I
chose for Scale. Any help please?

x=c(84390255386 ,84390255386, 78028317380 ,53594648044,422)
y=c(949849442 ,941645043, 840135292, 74, 821632939)
z=c(0.005641896, 0.005641896 ,0.005641896, 0.007978846,0.007978846)

convertToRadius<-function(x){return(sqrt(x/pi))}

scale=0.3

xlims =c(min(x),max(x))
ylims =c(min(y),max(y))
z=convertToRadius(z)*scale

symbols(x,y, circles=z,  fg='red')

thanks
Alireza

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: plot circles where z values are circles radius

Kehl Dániel
Hi,

see the help and especially the argument inches:

Argument inches controls the sizes of the symbols. If TRUE (the default), the symbols are scaled so that the largest dimension of any symbol is one inch. If a positive number is given the symbols are scaled to make largest dimension this size in inches (so TRUE and 1 are equivalent). If inches is FALSE, the units are taken to be those of the appropriate axes. (For circles, squares and stars the units of the x axis are used. For boxplots, the lengths of the whiskers are regarded as dimensions alongside width and height when scaling by inches, and are otherwise interpreted in the units of the y axis.)

Try

scale=500000000000

xlims =c(min(x),max(x))
ylims =c(min(y),max(y))
z=convertToRadius(z)*scale

symbols(x,y, circles=z,  fg='red', inches=FALSE)

HTH
kd
________________________________________
Feladó: R-help [[hidden email]] ; meghatalmaz&#243;: Dr. Alireza Zolfaghari [[hidden email]]
Küldve: 2015. január 23. 22:12
To: R-help; [hidden email]
Tárgy: [R] plot circles where z values are circles radius

Hi there,
I am trying to plot z values using Circle symbol. Each x and y has a value
which will be plotted using a circle where circle's radius is corrlated
with the value of z.

I wrote the code , but unable to change the size of circle no matter what I
chose for Scale. Any help please?

x=c(84390255386 ,84390255386, 78028317380 ,53594648044,422)
y=c(949849442 ,941645043, 840135292, 74, 821632939)
z=c(0.005641896, 0.005641896 ,0.005641896, 0.007978846,0.007978846)

convertToRadius<-function(x){return(sqrt(x/pi))}

scale=0.3

xlims =c(min(x),max(x))
ylims =c(min(y),max(y))
z=convertToRadius(z)*scale

symbols(x,y, circles=z,  fg='red')

thanks
Alireza

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: plot circles where z values are circles radius

Thomas Adams-2
In reply to this post by Dr. Alireza Zolfaghari
I think what you should look at are these web sites I found with a Google
search:

http://flowingdata.com/2010/11/23/how-to-make-bubble-charts/
http://www.r-bloggers.com/bubble-plots-ggplot2/
http://cran.r-project.org/web/packages/HSAUR/vignettes/Ch_logistic_regression_glm.pdf
http://cran.r-project.org/web/packages/mapplots/mapplots.pdf


Cheers!
Tom

On Fri, Jan 23, 2015 at 2:12 PM, Dr. Alireza Zolfaghari <
[hidden email]> wrote:

> Hi there,
> I am trying to plot z values using Circle symbol. Each x and y has a value
> which will be plotted using a circle where circle's radius is corrlated
> with the value of z.
>
> I wrote the code , but unable to change the size of circle no matter what I
> chose for Scale. Any help please?
>
> x=c(84390255386 ,84390255386, 78028317380 ,53594648044,422)
> y=c(949849442 ,941645043, 840135292, 74, 821632939)
> z=c(0.005641896, 0.005641896 ,0.005641896, 0.007978846,0.007978846)
>
> convertToRadius<-function(x){return(sqrt(x/pi))}
>
> scale=0.3
>
> xlims =c(min(x),max(x))
> ylims =c(min(y),max(y))
> z=convertToRadius(z)*scale
>
> symbols(x,y, circles=z,  fg='red')
>
> thanks
> Alireza
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: plot circles where z values are circles radius

Jim Lemon-4
Hi Alireza,
Part of the problem is the scale of your numbers. You probably want
something like this.

plot(x,y,cex=z/min(z)*2)

What happens here is that the default plotting character, which
happens to be a circle, is plotted in a size relative to the ratio of
each z value to the minimum z value. This is because the default value
of cex is 1. I have multiplied the result by 2 to make what is
happening more obvious. If you want to generate circles with specific
diameters, you will have to scale these to the area of the plot in
user units - see par("usr").

Jim


On Sat, Jan 24, 2015 at 8:29 AM, Thomas Adams <[hidden email]> wrote:

> I think what you should look at are these web sites I found with a Google
> search:
>
> http://flowingdata.com/2010/11/23/how-to-make-bubble-charts/
> http://www.r-bloggers.com/bubble-plots-ggplot2/
> http://cran.r-project.org/web/packages/HSAUR/vignettes/Ch_logistic_regression_glm.pdf
> http://cran.r-project.org/web/packages/mapplots/mapplots.pdf
>
>
> Cheers!
> Tom
>
> On Fri, Jan 23, 2015 at 2:12 PM, Dr. Alireza Zolfaghari <
> [hidden email]> wrote:
>
>> Hi there,
>> I am trying to plot z values using Circle symbol. Each x and y has a value
>> which will be plotted using a circle where circle's radius is corrlated
>> with the value of z.
>>
>> I wrote the code , but unable to change the size of circle no matter what I
>> chose for Scale. Any help please?
>>
>> x=c(84390255386 ,84390255386, 78028317380 ,53594648044,422)
>> y=c(949849442 ,941645043, 840135292, 74, 821632939)
>> z=c(0.005641896, 0.005641896 ,0.005641896, 0.007978846,0.007978846)
>>
>> convertToRadius<-function(x){return(sqrt(x/pi))}
>>
>> scale=0.3
>>
>> xlims =c(min(x),max(x))
>> ylims =c(min(y),max(y))
>> z=convertToRadius(z)*scale
>>
>> symbols(x,y, circles=z,  fg='red')
>>
>> thanks
>> Alireza
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.