Displaying 20 results from an estimated 54 matches for "scale_colour_manual".
2012 Nov 07
1
change colour of geom_step by scale_colour_manual
...p(direction="hv", size=3.0)+
scale_y_continuous("Rates of initiating first orientation flight",
limits=c(0,0.6), expand=c(0,0), breaks=c(0,0.2,0.4,0.6)) +
scale_x_continuous("Age of adults (days)", limits=c(0,16),
expand=c(0,0), breaks=c(5, 10, 15)) +
scale_colour_manual(name="Group",
breaks=c('ace', 'ctrlAM','met'),
labels=c("acetone", "untreated","methoprene"),
values=c("black","grey","red"))...
2009 Jul 28
2
Density plot in ggplot2
...all, I was trying to draw a stacked density plot like that :
library(ggplot2); library(plyr)
dat <- cbind(rnorm(300), rep(c(1,2), each=150))
ggplot() + geom_density(aes(x=dat[,1], fill=factor(dat[,2]),
position="stack")) +
xlab("") + ylab("") +
scale_colour_manual(name = "Pallet", labels = c("X", "Y"))
Here everything is ok, except few points :
1. I want to remove the name of y-axis, which is by default "density". Here
I put ylab(""), however although for x-axis it is working, for y-axis it is
not. Is there...
2011 Jan 30
2
ggplot2 -- scale_colour_manual()
According to Hadley's ggplot book (p. 109), both the graphs below should have a legend, and yet none appears in my hands.
Any suggestions? I can't see a typo. Is there a bug?
library(ggplot2)
data(LakeHuron)
huron = data.frame(year=1875:1972,level=LakeHuron)
p = ggplot(huron, aes(year)) +
geom_line(aes(y= level - 5), colour = 'blue') +
geom_line(aes(y= level + 5), colour
2010 Oct 20
1
Adding Legend about two quantile lines at ggplot
...ed")+stat_quantile(quantiles=c(0.90),col="blue",size=2)
I like to add legend indicating the information of "thick-blue line = 90%
line" & "thin-red line = 50% line".
Of course, I hope this legend should have same visual line with the plot.
I tried to use 'scale_colour_manual' function, but it did not work.
Could anyone give a advice for me?
- YNK
[[alternative HTML version deleted]]
2017 Oct 12
2
dual y-axis for ggplot
...ing the secondary axis, following the example in the help file
?scale_y_continuous
# and, very important, reverting the above transformation
p <- p + scale_y_continuous(sec.axis = sec_axis(~.*5, name = "Relative
humidity [%]"))
# modifying colours and theme options
p <- p + scale_colour_manual(values = c("blue", "red"))
p <- p + labs(y = "Air temperature [?C]",
x = "Date and time",
colour = "Parameter")
p <- p + theme(legend.position = c(0.8, 0.9))
p
########
Thanks,
John
[[alternative HTML...
2017 Oct 12
1
dual y-axis for ggplot
...eom_line(aes(y = air_temp, colour = "Temperature", linetype
="Temperature"))
p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity",
linetype="Humidity"))
p <- p +
guides(colour=guide_legend(override.aes=list(linetype=override.linetype)))
p <- p + scale_colour_manual(values = c("blue", "red"))
p <- p + scale_linetype_manual(values = c("twodash", "solid"),guide=FALSE)
p
I searched for help and used the info I found at this link:
https://stackoverflow.com/questions/37140266/how-to-merge-color-line-style-and-shape-legend...
2017 Nov 29
3
Removing a data subset
...;- ifelse(MyData$D_GW_Elv ==1, "Detected", "NonDetect")
#Removes the NAs
MyDataWONA <- MyData[!is.na(MyData$Detections), ]
#does the plot
p <- ggplot(data = MyDataWONA, aes(x=Year, y=GW_Elv , col=Detections)) +
geom_point(aes(shape=Detections)) +
##sets the colors
scale_colour_manual(values=c("black","red")) + #scale_y_log10() +
#location of the legend
theme(legend.position=c("right")) +
#sets the line color, type and size
geom_line(colour="black", linetype="dotted", size=0.5) +
ylab("Elevation Feet Mean Sea Lev...
2011 Jul 12
1
problem plotting points based on different values
Hello Friends,
I am new to R and stuck with a problem.
i have two columns drug_A and drug_B, i have plotted a scatter plot
using the ggplot2 function.
My problem is with the third column, it is the p-value column.
I want to color and size points differently based on the p_value, the
p_value range is between 0<0.0001< 0.001<0.05<1.
I used a script using the ifelse loop, but it
2011 Jul 08
1
Referencing a vector of data labels in ggplot function
...r))
p2 <- p + geom_line(size = 1)
# + opts(title = plotName)
p2 <- p2 + facet_grid(Facet~., scales = 'free') +
# p2 <- p2 + geom_text(data = dframe[dframe[,'date'] == '1941-06-16',],
# aes(date, value, label = lineNames, vjust = 1)) +
scale_colour_manual(values = colors)
}
finalP <- withNames(data, plines, pTitle, col1)
#finalP <- simple(data)
[[alternative HTML version deleted]]
2017 Oct 12
0
dual y-axis for ggplot
...the example in the help file
> ?scale_y_continuous
> # and, very important, reverting the above transformation
> p <- p + scale_y_continuous(sec.axis = sec_axis(~.*5, name = "Relative
> humidity [%]"))
>
> # modifying colours and theme options
> p <- p + scale_colour_manual(values = c("blue", "red"))
> p <- p + labs(y = "Air temperature [?C]",
> x = "Date and time",
> colour = "Parameter")
> p <- p + theme(legend.position = c(0.8, 0.9))
> p
> ########
>
>...
2024 Mar 05
1
How to invert axis within defined range with ggplot2 scale_y_reverse?
...78, 22.49, 21.85, 22.2)
df <- data.frame(Conc = A, Time = B, Value = V)
df$Conc = as.factor(df$Conc)
df$Time = as.factor(df$Time)
library(ggplot2)
ggplot(df, aes(x=Time, y=Value, colour=Conc, group=Conc)) +
geom_line() +
scale_y_reverse(limits = c(20,30)) +
geom_point(size=6) +
scale_colour_manual(values = COLS)
> Warning messages:
1: Removed 15 rows containing missing values (`geom_line()`).
2: Removed 15 rows containing missing values (`geom_point()`).
```
2024 Mar 05
1
How to invert axis within defined range with ggplot2 scale_y_reverse?
...ame(Conc = A, Time = B, Value = V)
> df$Conc = as.factor(df$Conc)
> df$Time = as.factor(df$Time)
> library(ggplot2)
>
> ggplot(df, aes(x=Time, y=Value, colour=Conc, group=Conc)) +
> geom_line() +
> scale_y_reverse(limits = c(20,30)) +
> geom_point(size=6) +
> scale_colour_manual(values = COLS)
The limits should be `c(30,20)`.
Duncan Murdoch
2008 Jun 10
1
Sweave, ggplot2 and two-page figures
...quot;, xlab="Days of
Follow-up", ylab="Daysto First AR") + geom_smooth(aes(group=bos2),
method='rlm', fill=alpha("grey", 0.4)) +
scale_shape(solid=FALSE,name="BOS\nFalse = 0\nTrue = 1") +
scale_size_identity() + facet_grid(bos2 ~ ., margins=TRUE)
+scale_colour_manual(name="BOS\nFalse = 0\nTrue = 1", values=c("blue",
"purple")))
grid.gedit(gPath("strip","label"),gp=gpar(fontsize="14", col="red"))
@
I am unable to get the plot with the modified strip labels to be
included. It is created as th...
2009 Dec 01
1
ggplot legend for multiple time series
...Wickman (2009, ggplot2 - elegant graphics for data
analysis, page 109)
library(ggplot2)
huron <- data.frame(year=1875:1972, level=LakeHuron)
ggplot(huron, aes(year)) +
geom_line(aes(y=level+5, colour="above")) +
geom_line(aes(y=level-5, colour="below")) +
scale_colour_manual("Direction", c("above"="black",
"below"="black"))
Thanks,
Edwin
Changyou Sun, Ph.D.
Associate Professor
Natural Resource Policy & Economics
Box 9681, Department of Forestry
Mississippi State University
Mississippi State, MS 3...
2010 Jan 27
1
ggplot2 theme for custom point colors?
1. Is it possible to set the point colors in a ggplot2 theme? For example,
to default to these colors:
scale_colour_manual(value = c("red", "orange", "yellow", "green", "blue")
2. Is it possible to set this theme in .Rprofile, similar to:
my.lattice.colors = function () { .......etc.....}
options(lattice.theme=".mw.lattice.colors")
--
Kevin Wright
[[alte...
2010 Mar 24
1
GGPLOT2: Reverse order of legend to match order of x-axis
...the legend to match the
stacked colors of the bar plot. I tried this, but it didn't work.
colors <- c("5" = "red","4" = "blue","3" = "darkgreen")
p <- qplot(factor(cyl), data=mtcars, geom="bar", fill=factor(gear))
p + scale_colour_manual(name = "gear",values = colors,breaks =
c("5","4","3"),labels = c("5 speed","4 speed","3 speed"))
http://n4.nabble.com/file/n1689526/plot.jpeg
--
View this message in context: http://n4.nabble.com/GGPLOT2-Reverse-order-of-legen...
2010 Nov 23
1
specifying colours in a ggplot2 piechart
...p = "orange" )
pie1 <- ggplot(mypie, aes(x = factor(zz), fill = factor(zz))) + geom_bar(width = 1)
pie2 <- pie + coord_polar(theta = "x") + scale_colour_brewer(Pastel1)
pie2
# try to get even nastier piechart with ugly colours to provide rast.
pie3 <- pie2 + scale_colour_manual(value=mycolours)
pie
2011 Sep 15
1
changing "label" in ggplot
Hi everyone,
I'm trying to create a scatterplot (with ggplot2) with different groups and
a faceting (see code below... much clearer I think)
But when I want to change the color label to something else using the
scale_colour_manual function (based on
http://had.co.nz/ggplot2/scale_manual.html), it seems impossible to get what
I want. Instead I receive a nice error message.
But the code will speak for itself if my request doesn't seem clear enough
to you guys.
Code:
> g<- ggplot(data=d, aes(x=Xcontinuous,y=Ycont...
2023 Jul 02
0
How to plot both lines and points by group on ggplot2
...ls(df$Time) = c(1, 4, 24)
> > df$Conc <- as.factor(df$Conc)
> > levels(df$Conc) = c(1, 2, 5)
> > library(ggplot2)
> > ggplot(df, aes(x=Time, y=Value, colour=Conc)) +
> > geom_point(size=6) +
> > geom_line(aes(x=Time, y=Value, colour=Conc)) +
> > scale_colour_manual(values = c("darkslategray3", "darkslategray4",
> > "deepskyblue4")) +
> > ggtitle("Working example") +
> > xlab(expression(bold("Time (h)"))) +
> > ylab(expression(bold("Concent...
2017 Nov 29
0
Removing a data subset
...;, "NonDetect")
>
> #Removes the NAs
> MyDataWONA <- MyData[!is.na(MyData$Detections), ]
>
> #does the plot
> p <- ggplot(data = MyDataWONA, aes(x=Year, y=GW_Elv , col=Detections)) +
> geom_point(aes(shape=Detections)) +
>
> ##sets the colors
> scale_colour_manual(values=c("black","red")) + #scale_y_log10() +
>
> #location of the legend
> theme(legend.position=c("right")) +
>
> #sets the line color, type and size
> geom_line(colour="black", linetype="dotted", size=0.5) +
> yla...