Displaying 20 results from an estimated 112 matches for "linetype".
2017 Oct 12
1
dual y-axis for ggplot
Hi John,
You can try the following:
override.linetype=c("twodash","solid")
p <- ggplot(obs, aes(x = Timestamp))
p <- p + geom_line(aes(y = air_temp, colour = "Temperature", linetype
="Temperature"))
p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity",
linetype="Humidity"))
p &l...
2017 Oct 12
2
dual y-axis for ggplot
...nt 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 linetype "solid"?
For convenience, I copied the codes as follows.
########
p <- ggplot(obs, aes(x = Timestamp))
p <- p + geom_line(aes(y = air_temp, colour = "Temperature"))
# adding the relative humidity data, tra...
2017 Oct 12
0
dual y-axis for ggplot
Sorry let me clarify.
If I modify the line
p <- p + geom_line(aes(y = air_temp, colour = "Temperature"))
by
p <- p + 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")...
2018 Jul 18
2
Legendas en una gráfica de ggplot2
...7
t=seq (-4, 4, by=0.01)
i=exp(t-0.7)/(1+(exp(t-0.7)))
### Con b igual a 2
t=seq (-4, 4, by=0.01)
u=exp(t-2)/(1+(exp(t-2)))
####unir los datos
b=c(0.3,2,-1,-2)
datos=cbind(l,o,i,u)
datos=data.frame(datos)
###Graficos
ggplot( )+
geom_line(aes(y = i, x=t), color="gray48", size=1.2, linetype="dashed") +
geom_line(aes(y = u, x=t), color = "gray48", size=1.2,linetype="twodash")+
geom_line(aes(y = o,x=t), color = "gray48",
size=1.2,linetype="longdash") +
geom_line(aes(y = l,x=t), color="gray48", size=1.2,linetype="so...
2009 Sep 09
2
ggplot2: mixing colour and linetype in geom_line
Hi all,
I try to represent a multiple curve graphic where the x-axis is the
temperature and the different y-axes are the different X (X22,X43,X44...)
some X corresponds to the same molecule (22 and 44 are for CO2 for instance)
so I use the same colour for them.
I wanna mix the linetype with the colour to be able to visually see the
difference between X43 and X45
The best I have done up to now is this code but it crashes with :"Error in
col2rgb(colour, TRUE) : invalid color name 'AA'"
if I skip the linetype in geom it works perfectly of course
THT_N2_ATGMS_...
2018 Jul 18
2
Legendas en una gráfica de ggplot2
...ctor Granda García <
victorgrandagarcia en gmail.com> escribió:
> Hola Sebastián.
>
> Entiendo que tratas de que aparezca una leyenda con el tipo de curva
> (l,o,u,i). Si quieres aprovechar las ventajas de ggplot (como las leyendas
> automáticas) normalmente tienes que asignar linetype a una variable, y para
> eso tienes que modificar un poco tus datos. Los has creado en formato
> "wide" (ancho), donde tienes la columna t y una columna para cada curva.
> Pero para lo que quieres hacer en ggplot, necesitas un formato "long"
> (largo), donde tienes u...
2024 Jul 18
1
ggplot two-factor legend
...escreveu:
> ?s 16:27 de 18/07/2024, SIBYLLE ST?CKLI via R-help escreveu:
>> Hi
>>
>> I am using ggplot to visualise y for a two-factorial group (Bio: 0 and
>> 1) x
>> = 6 years. I was able to adapt the colour of the lines (green and red)
>> and
>> the linetype (solid and dashed).
>> Challenge: my code produces now two legends. One with the colors for the
>> group and one with the linetype for the group. Does somebody have a
>> hint how
>> to adapt the code to produce one legend? Group 0 = red and dashed,
>> Group 1 =
>&...
2018 May 22
3
legend order in ggplot2
...",
while it corresponds to "dashed", etc, which I don't want. How could I make
"solid" correspond to "name_b"? Thanks,
#########
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...
2023 Aug 12
1
geom_smooth
...var = runif(100, min = 0, max = 25)
> ?????????????????????? ,y_var = log2(x_var) + rnorm(100))
>
> library(ggplot2)
> library(cowplot)
>
> ggplot(scatter_data,aes(x=x_var,y=y_var))+
> ? geom_point()+
> ? geom_smooth(se=TRUE,fill="blue",color="black",linetype="dashed")+
> ? theme_cowplot()
>
> I'd like to add a black boundary around the shaded area. I suspect this can be done with geom_ribbon but I cannot figure this out. Some advice would be welcome.
>
> Thanks!
>
> Thomas Subia
>
> ________________________...
2013 Feb 01
2
Change default order of colors & line types
...r 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 graph is
qplot(variable, power, data = m.powers, colour = method,
linetype=method, ylab = "Power") + geom_line(aes(group = method),
ylim = c(0,1)) +
scale_colour_brewer(palette="Set1")
T...
2013 Mar 06
6
Ggplot2: Moving legend, change fill and removal of space between plots when using grid.arrange() possible use of facet_grid?
...ean,
colour = factor1, group = factor1,
shape = factor1)) +
geom_point(aes(shape=factor(factor1)), color="black", fill="white",
position = "dodge", width = 0.3, size=3) +
geom_line(aes(linetype=factor1), color = "black", size = 0.5) +
geom_errorbar(aes(ymin = mean - sdv , ymax = mean + sdv), width = 0.3,
position = "dodge", color = "black", size=0.3) +
theme_bw() +
ylab(expression(paste("my measured stuff"))) +
xlab("f...
2009 Jan 22
5
Combining Custom and Preset Linetypes
...I have the problem of
trying to get the new line into the legend. Does anyone have any ideas
about how to combine custom and preset line types?
Regards,
James
http://www.nabble.com/file/p21593760/CRA.gif
--
View this message in context: http://www.nabble.com/Combining-Custom-and-Preset-Linetypes-tp21593760p21593760.html
Sent from the R help mailing list archive at Nabble.com.
2024 Jul 18
1
ggplot two-factor legend
?s 16:27 de 18/07/2024, SIBYLLE ST?CKLI via R-help escreveu:
> Hi
>
> I am using ggplot to visualise y for a two-factorial group (Bio: 0 and 1) x
> = 6 years. I was able to adapt the colour of the lines (green and red) and
> the linetype (solid and dashed).
> Challenge: my code produces now two legends. One with the colors for the
> group and one with the linetype for the group. Does somebody have a hint how
> to adapt the code to produce one legend? Group 0 = red and dashed, Group 1 =
> green and solid?
>
>
>...
2024 Jul 18
1
ggplot two-factor legend
...anyway.
On July 18, 2024 8:27:05 AM PDT, "SIBYLLE ST?CKLI via R-help" <r-help at r-project.org> wrote:
>Hi
>
>I am using ggplot to visualise y for a two-factorial group (Bio: 0 and 1) x
>= 6 years. I was able to adapt the colour of the lines (green and red) and
>the linetype (solid and dashed).
>Challenge: my code produces now two legends. One with the colors for the
>group and one with the linetype for the group. Does somebody have a hint how
>to adapt the code to produce one legend? Group 0 = red and dashed, Group 1 =
>green and solid?
>
>
>MS1&l...
2024 Jul 18
2
ggplot two-factor legend
Hi
I am using ggplot to visualise y for a two-factorial group (Bio: 0 and 1) x
= 6 years. I was able to adapt the colour of the lines (green and red) and
the linetype (solid and dashed).
Challenge: my code produces now two legends. One with the colors for the
group and one with the linetype for the group. Does somebody have a hint how
to adapt the code to produce one legend? Group 0 = red and dashed, Group 1 =
green and solid?
MS1<- MS %>% filter(QI_A!=&...
2023 Aug 12
2
geom_smooth
...h
set.seed(55)
scatter_data <- tibble(x_var = runif(100, min = 0, max = 25)
?????????????????????? ,y_var = log2(x_var) + rnorm(100))
library(ggplot2)
library(cowplot)
ggplot(scatter_data,aes(x=x_var,y=y_var))+
? geom_point()+
? geom_smooth(se=TRUE,fill="blue",color="black",linetype="dashed")+
? theme_cowplot()
I'd like to add a black boundary around the shaded area. I suspect this can be done with geom_ribbon but I cannot figure this out. Some advice would be welcome.
Thanks!
Thomas Subia
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=
2012 Jan 19
1
Legend problem in line charts
...xis
xrange <- range(refid1$TIME1)
yrange <- range(refid1$BASCHGA)
# set up the plot
pdf (paste("pga", i, ".pdf", sep=''))
print(plot(xrange, yrange, type="n", xlab="TIME1 (WK)",
ylab="BASCHGA (mm)" ))
colors <- rainbow(nACTTRTs)
linetype <- c(1:nACTTRTs)
plotchar <- seq(18,18+nACTTRTs,1)
# add lines
for (i in 1:nACTTRTs) {
ACTTRT <- subset(refid1, ACTTRTnum==i)
print(lines(ACTTRT$TIME1, ACTTRT$BASCHGA, type="b", lwd=1.5,
lty=linetype[i], col=colors[i], pch=plotchar[i]))
}
# add a title and subtitle
pas...
2006 Oct 16
2
set linetype with plotCI
Dear R-list,
I'm iterating several calls to plotCI [gplots], like so:
plotCI(
x = xvals.f[sorted],
y = yvals.f[sorted],
xlim = c(xmin, xmax), ylim = c(ymin, ymax),
pch = plot_symbols[graph_idx], type = "b",
lty = plot_linetypes[1],
col = plot_colors[graph_idx],
barcol = plot_colors[graph_idx], uiw = NA,
xlab = "", ylab = "",
add = (plot_cnt > 0)
)
This works fine, the result is four graphs exactly like I want them.
Except for one thing, the lty is not used.
I understand this is because...
2018 May 23
3
Change the legend order by order function
...bottom.
Could it be done by order function or its inverse?
Thanks,
##### source code
library(ggplot2)
od<-order(c("name_b", "name_c", "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","...