Plotting circle

386 views
Skip to first unread message

Christofer Bogaso

unread,
Aug 20, 2010, 7:32:57 AM8/20/10
to ggp...@googlegroups.com
Dear all,

Instead of plotting "points" as different sizes I would like to plot
those points as "circle", whose width of the circumference would be
determined by some other variable (which would determine the size of
the points). And of course another option to determine the color of
the circumference would be great.

Can I do this with ggplot? I have gone through the online
documentation however could not find anything such.

Thanks for your time

Mark Connolly

unread,
Aug 20, 2010, 7:56:57 AM8/20/10
to Christofer Bogaso, ggp...@googlegroups.com
play around with this

ggplot(thedata) +
aes(x,y,size=radius,color=factor(radius)) + # x,y coordinates
geom_point(shape=1) #open circle

Mark Connolly

unread,
Aug 20, 2010, 8:10:23 AM8/20/10
to Christofer Bogaso, ggp...@googlegroups.com
I checked back on some stuff I had done before. This is what I did to
show the range of a geostatistics model fit. The solid circle with an
alpha value was more appropriate (for me).

ggplot(sl.df) + aes(x,y) +
geom_point(size=range,alpha=0.2,color=factor(range)) +
coord_equal(ratio=1)

Bogaso

unread,
Aug 23, 2010, 12:19:43 PM8/23/10
to ggplot2
Dear Mark, your idea of having a "shape" parameter works for me. Here
is my code:

dat = data.frame(x=runif(5), y=runif(5))
ggplot() + scale_x_continuous(limits = c(0,1)) +
scale_y_continuous(limits = c(0,1))+
geom_point(aes(x=x, y=y), data=dat, size=48, shape=1, color="gold4")

However I want to make the circumference of each circle ****more
thicker****. Is there any option to that, as per the user's choice?

Thanks,

Mark Connolly

unread,
Aug 23, 2010, 1:06:30 PM8/23/10
to Bogaso, ggplot2
If you just want thicker circles, look at various unicode characters.
For example, shape="\u25E6" gives you a thick-walled "white bullet".

You may need to leave behind the simplicity of shapes/symbols you need
to switch to constructing real geometric shapes. You can use geom_path
to draw open polygons with size controlling the line thickness.
However, I believe you will have to produce the shapes as data. This
means creating a path of segments such as you would if you wanted to
trace a circle. A function that takes a centerpoint, a radius, and a
segment density and returns a set of coordinates may be in order.

Bogaso

unread,
Aug 23, 2010, 1:19:26 PM8/23/10
to ggplot2
Thanks Mark for your suggestion. How can I find a list of other values
of shape="\u25E6"?

Thanks,

Mark Connolly

unread,
Aug 23, 2010, 1:28:02 PM8/23/10
to Bogaso, ggplot2
http://www.unicode.org/charts/

or google white bullet unicode

Reply all
Reply to author
Forward
0 new messages