Displaying 15 results from an estimated 15 matches for "scale_linetype_manu".
Did you mean:
scale_linetype_manual
2018 May 22
3
legend order in ggplot2
...#######
library(ggplot2)
df<-data.frame(x1=c(1,2), y1=c(3,4),z1=c(5,6),w1=c(7,8))
p1<-ggplot(df, aes(x=1:2, y=x1))+
geom_line(aes(linetype="name_b"))+
geom_line(aes(x=1:2, y=y1, linetype="name_a"), df)+
geom_line(aes(x=1:2, y=z1, linetype="name_c"), df)+
scale_linetype_manual(name="", values=c("solid","dashed", "dotted"),
breaks=c("name_b","name_a","name_c"))
###########
[[alternative HTML version deleted]]
2017 Oct 12
1
dual y-axis for ggplot
...mperature"))
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-legends-in-ggplot
HTH,
Eric
On Thu, Oct 12, 2017 at 10:14 AM, John <miaojpm at...
2018 May 23
1
legend order in ggplot2
...ine or legend is on the graph (as attached)
Am I doing anything wrong?
John
library(ggplot2)
library(reshape2)
dfm<-melt(df)
dfm$variable<-factor(dfm$variable, levels=levels(dfm$variable)[c(2,1,3,4)])
p2<-ggplot(dfm, aes(x=rep(1:2,4), y=value))
p2+geom_line(aes(linetype=variable))+
scale_linetype_manual(values=c("solid", "dashed", "dotted", "blank"),
labels=c("name_b","name_a","name_c", "other"))
2018-05-22 15:15 GMT+08:00 PIKAL Petr <petr.pikal at precheza.cz>:
> Hi
>
> Your...
2017 Oct 12
0
dual y-axis for ggplot
...+ geom_line(aes(y = air_temp, colour = "Temperature", linetype
="Temperature"))
and
p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity"))
by
p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity",
linetype="Humidity"))
and
p <- p + scale_linetype_manual(values = c("twodash", "solid")),
I will have two lines with different color and different line type,
but I will have two legends (one with blue/red,solid, the other with two
dash/solid, black ).
How can I have only one legend with blue/two dash and red/solid?
2017-10-1...
2018 May 22
0
legend order in ggplot2
...uld reshape data before plotting and maybe also change order of levels in resulting variable factor
library(reshape2)
dfm<-melt(df)
dfm$variable<-factor(dfm$variable, levels=levels(dfm$variable)[c(2,1,3,4)])
p2<-ggplot(dfm, aes(x=rep(1:2,4), y=value))
p2+geom_line(aes(linetype=variable))+
scale_linetype_manual(values=c("solid", "dashed", "dotted", "blank"),
labels=c("name_b","name_a","name_c", "other"))
Cheers
Petr
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of John...
2017 Oct 12
2
dual y-axis for ggplot
Hi,
To my knowledge, an excellent of ggplot with a second y-axis is
https://rpubs.com/MarkusLoew/226759
In this example, the author uses two colors for the two lines, but the
line shapes are the same -- both are solid. Could each line have its own
color as well as its own shape? For example, can I make the red line with
the linetype "twodash", while the blue line with the
2018 May 23
3
Change the legend order by order function
...quot;, "name_a"))
df<-data.frame(x1=c(1,2), y1=c(3,4),z1=c(5,6),w1=c(7,8))
p1<-ggplot(df, aes(x=1:2, y=x1))+
geom_line(aes(linetype="name_b"))+
geom_line(aes(x=1:2, y=y1, linetype="name_c"), df)+
geom_line(aes(x=1:2, y=z1, linetype="name_a"), df)+
scale_linetype_manual(name="", values=c("solid","dashed", "dotted")[(od)],
labels=c("name_b","name_c","name_a"))
#### supplement
> od
[1] 3 1 2
> order(od)
[1] 2 3 1
[[alternative HTML version deleted]]
2013 Feb 01
2
Change default order of colors & line types
Dear R users,
I'd like to change the default order of colors & line types.
Especially I am using ggplot2 and using color Set1.
In Set1, the default color order is red, blue, green, violet,.. ect.
However, I want to put red in fourth (not first).
Likewise, I want to change the order of default linetype. I want to
put "solid" line in fourth.
How can I do thses?
R code to draw the
2012 Oct 22
1
how to group smooth line by two groups?
...color plot with the following code. what should i change "color"
to?
pb <- ggplot(data, aes(x = a, y = b,
color = char, linetype = factor(sex)))
p0 <- pb +
scale_color_manual(values = c("#00FFFF", "#FFFF00", "#00FF00")) +
scale_linetype_manual(breaks=c("0","1"), values=c(1,2), labels = c("male",
"female")) +
geom_smooth(method = "lm",
se = FALSE, # Don't add shaded confidence region
size = 1.2, aes(group = char : sex))
<http://r.789695.n4.nabble.com...
2010 Dec 08
1
ggplot - line_range help, second tier axis label
...136,0.046444), var1 = c("1","1","2","2"), var2 =
c("A","B","A","B"), var1var2 = c("1A","1B","2A","2B"))
ggplot(figure4, aes(var1var2, cen, ymin = min, ymax=max, linetype=var1)) +
scale_linetype_manual(values = c(1,3)) + geom_pointrange() +
geom_errorbar(width=0.2) + opts(title="Title goes here") + labs(x="Var2",
y="Y units", linetype="Var1")
Thanks
Matt
[[alternative HTML version deleted]]
2018 May 23
0
Change the legend order by order function
...;))
>df<-data.frame(x1=c(1,2), y1=c(3,4),z1=c(5,6),w1=c(7,8))
>p1<-ggplot(df, aes(x=1:2, y=x1))+
> geom_line(aes(linetype="name_b"))+
> geom_line(aes(x=1:2, y=y1, linetype="name_c"), df)+
> geom_line(aes(x=1:2, y=z1, linetype="name_a"), df)+
>scale_linetype_manual(name="", values=c("solid","dashed",
>"dotted")[(od)],
>labels=c("name_b","name_c","name_a"))
>
>
>#### supplement
>> od
>[1] 3 1 2
>> order(od)
>[1] 2 3 1
--
Sent from my phone. Please excuse...
2011 Nov 08
2
nesting scale_manual caracteristics in ggplot
...39;grey','D'='grey',
'E'='red','F'='grey', 'G'='red'), labels=c('A: Line 1','B: Line 2','C:
Line3','D: Line 4',
'E: Line 5 ','F:Line 6','G:Line 7'))+
scale_linetype_manual(breaks=c('A','B','C','D','E','F','G'),
values=c('A'='solid','B'='dotted', 'C'='solid','D'='dashed',
'E'='dashed','F'='dotted', 'G'='d...
2016 Apr 09
1
Run script R
...0), labels=function(x){x/1000}) +? scale_x_continuous ("Time, seconds", limits=c(0,2)) +? scale_colour_brewer("Distance between cars, m", palette="Dark2", guide = "none") +? scale_fill_brewer("Distance between cars, m", palette="Dark2") +? scale_linetype_manual("Distance between cars, m", values=c(1,2,3,4,5,6,7,8)) +? theme_custom () +? theme (legend.position = c(0.99,-0.05), legend.justification=c(1.0,0), legend.direction = "horizontal")
if (!file.exists ("graphs/pdfs")) {? dir.create ("graphs/pdfs")}
pdf (output...
2008 Mar 25
1
Combining several mappings in ggplot2
...lot(data = Orange, aes(x = age, y = circumference, color = Tree)) +
geom_line()
if i try this I get an error:
ggplot(data = Orange, aes(x = age, y = circumference, color = Tree,
linetype = Tree)) + geom_line()
or
ggplot(data = Orange, aes(x = age, y = circumference, color = Tree)) +
geom_line() + scale_linetype_manual(value = c(1:5))
I'd be grateful to get a suggestion of how to do this.
Regards,
TL
2009 Feb 18
1
lineplot in ggplot2 with different colour and linetype
Hi list,
I would like to use ggplot2 in creating a line plot with 4 lines (groups), 2
of which I want in colour and the remaining two as dotted lines.
### R code ###
library(ggplot2)
### create data ####
vals <- rnorm(400)
div<- c(rep("A",100),rep("B",100),rep("C",100),rep("D",100))
n<- rep(1:100,4)
df<- data.frame(div=