Many thanks.
Lorenzo
##############################################################################�
library(ggplot2)
# Generate data
myear <- ddply(movies, .(year), colwise(mean, .(length, rating)))
p <- ggplot(myear, aes(length, rating))
p + geom_path()
# Add aesthetic mappings
p + geom_path(aes(size = year))
#add new column to dataframe
myear$extra<-rev(myear$rating)
scale_size(breaks = c(1893, 1950, 2005))
> (2) I added a new column to my dataframe (myear$extra): is there any way
> I can represent this as a color and fine tune the corresponding legend
> as well? This way I would have a plot where the line changes both in
> size and color.
geom_path(aes(size = year, colour = extra))
scale_colour_continuous() #use to define breaks, labels, etc.
> Many thanks.
>
> Lorenzo
>
> ##############################################################################�
>
> library(ggplot2)
> # Generate data
> myear <- ddply(movies, .(year), colwise(mean, .(length, rating)))
> p <- ggplot(myear, aes(length, rating))
> p + geom_path()
>
> # Add aesthetic mappings
> p + geom_path(aes(size = year))
>
> #add new column to dataframe
> myear$extra<-rev(myear$rating)
Must rerun assignment to p after adding the column; otherwise p doesn't
know about the column.
ggplot(myear, aes(length, rating)) +
geom_path(aes(size = year, colour = extra)) +
scale_size(breaks = c(1893, 1950, 2005)) +
scale_colour_continuous()
--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University
p <- ggplot(myear, aes(x = length, y = rating))
p + geom_path(aes(size = year, colour = extra)) +
scale_size(breaks = c(1893, 1950, 2005)) +
scale_colour_gradient2(low = 'black', mid = 'dodgerblue', high = 'orange',
midpoint = 6.0, breaks = c(4.5, 6.0, 7.0))
HTH,
Dennis
On Tue, Jul 19, 2011 at 1:18 PM, Lorenzo Isella
<lorenzo...@gmail.com> wrote:
> Dear All,
> Please consider the snippet at the end of the email.
> I would like to do some fine tuning of the resulting plot, namely
> (1) have more control of what I see in the legend: e.g. I would like to show
> 1893, 1950 and 2005 as years in the legend.
> (2) I added a new column to my dataframe (myear$extra): is there any way I
> can represent this as a color and fine tune the corresponding legend as
> well? This way I would have a plot where the line changes both in size and
> color.
>
> Many thanks.
>
> Lorenzo
>
> ##############################################################################à
> library(ggplot2)
> # Generate data
> myear <- ddply(movies, .(year), colwise(mean, .(length, rating)))
> p <- ggplot(myear, aes(length, rating))
> p + geom_path()
>
> # Add aesthetic mappings
> p + geom_path(aes(size = year))
>
> #add new column to dataframe
> myear$extra<-rev(myear$rating)
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>