change the shape

10 views
Skip to first unread message

Alfredo

unread,
Mar 29, 2011, 6:53:58 AM3/29/11
to ggplot2
Hi,

I've this dataset:

STAZIONE AREA CURVA E N
1 VCH 1 RS 13.73385 41.83002
2 VCH 2 NE 13.73265 41.83066
3 VCH 3 RS 13.73305 41.82984
4 VCHO 4 NS 13.72989 41.82922
5 VCHO 5 NS 13.73112 41.82926


p <- ggplot(dati, aes(E, N))

p + stat_contour(data = dem, aes(x, y, z = z)) +
geom_point(aes(colour = CURVA), size = 4) +
geom_point(colour="grey90", size = 1.5) +
scale_colour_brewer(palette="Set1") +
opts(panel.grid.major=theme_blank())


How can I change the shape based of the field STAZIONE?



Thanks in advance,

Alfredo





Brandon Hurr

unread,
Mar 29, 2011, 8:03:42 AM3/29/11
to Alfredo, ggplot2
Alfredo, 

We're missing some of your data so I took out the stat_contour() call. 

dati <- structure(list(STAZIONE = structure(c(1L, 1L, 1L, 2L, 2L), .Label = c("VCH", 
"VCHO"), class = "factor"), AREA = 1:5, CURVA = structure(c(3L, 
1L, 3L, 2L, 2L), .Label = c("NE", "NS", "RS"), class = "factor"), 
    E = c(13.73385, 13.73265, 13.73305, 13.72989, 13.73112), 
    N = c(41.83002, 41.83066, 41.82984, 41.82922, 41.82926)), .Names = c("STAZIONE", 
"AREA", "CURVA", "E", "N"), class = "data.frame", row.names = c(NA, 
-5L))

ggplot(dati, aes(E, N))+
geom_point(aes(colour = CURVA, shape=STAZIONE), size = 4) +
geom_point(colour="grey90", size = 1.5) +
scale_colour_brewer(palette="Set1") +
opts(panel.grid.major=theme_blank())

Does this do what you want? 

Brandon

Alfredo Alessandrini

unread,
Mar 29, 2011, 9:18:14 AM3/29/11
to Brandon Hurr, ggplot2
I've try this and now it works:

p <- ggplot(dati, aes(E, N))

p + stat_contour(data = dem, aes(x, y, z = z)) +
geom_point(aes(colour = CURVA), size = 4) +

geom_point(colour="grey90", aes(shape = STAZIONE)) +
scale_colour_brewer(palette="Set1")

Thanks for the help,

Alfredo


2011/3/29 Brandon Hurr <brando...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages