Displaying 20 results from an estimated 292 matches for "geom_lin".
Did you mean:
geom_line
2017 Oct 12
2
dual y-axis for ggplot
...h 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, transformed to match roughly the
range of the temperature
p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity"))
# now adding the secondary axis, following the example in the help fi...
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 <- p +
guides(colour=guide_legend(override.aes=list(linetype=override.linetype)))
p <- p + scale_c...
2012 Feb 16
2
Problem building up ggplot graph in a loop.
Folks,
I want to automate some graphing using ggplot.
Here is my code
graphChargeOffs2<-function(coffs) {
ggplot(coffs, aes(levels))
dataNames<-names(coffs)[!names(coffs) == "levels"]
for(i in dataNames) {
thisData<-coffs[[i]]
last_plot() + geom_line(aes(y = thisData, colour = i))
}
last_plot() + ylab("Total Chargeoffs")
}
coffs is a data.frame.
I get the following error:
Error in eval(expr, envir, enclos) : object 'thisData' not found
As little as I know about environments in R I am pretty sure that the geom_line in t...
2013 Jan 02
0
How to use geom_line (from ggplot) with aesthetics in a function?
Hello,
I have been struggling with this for a while, tried a few things, but no
clean solution so far. Here is an example from the documentation for
geom_line:
==========================================
# Summarise number of movie ratings by year of movie
mry <- do.call(rbind, by(movies, round(movies$rating), function(df) {
nums <- tapply(df$length, df$year, length)
data.frame(rating=round(df$rating[1]), year = as.numeric(names(nums)),
number...
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 = &q...
2009 Apr 17
0
Mischief on legend when size=1 added to geom_line
Hi Arthur:
# Just move size outside 'aes' like this:
p <- ggplot(df1, aes(Year, PctProf, group = Group))
p + geom_line(aes(color = Group),size=1)
# to make the background white just use the black and white theme:
p <- ggplot(df1, aes(Year, PctProf, group = Group))
p + geom_line(aes(color = Group),size=1) + theme_bw()
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish &am...
2012 Jan 16
1
ggplot- using geom_point and geom_line at the same time
Hi
I am plotting line chart using ggplot and want to use geom_line and
geom_point simultaneously.
I get the plot but now I have two legends. None of the legend is
representing the true values. I need the legend with shape and color both.
Thanks
> con = textConnection("inputs var1 var2 var3+ 100 10 5 2+ 1000 20 10 4+ 5000 30 15 8+ 10000 40 20 16+ 3000...
2012 Sep 25
1
geom_line: How to plot two data sets having different maximum X-axis values in a single plot?
...ed to learn R and ggplot2. Can someone help?
How to plot two data sets having different maximum X-axis values in a
single plot?
For example, I have two data sets showed below. Using position as X, and
count as Y, how can I plot them out in different color lines within a
single plot using ggplot2 geom_line?
dataset a:
position count
1 3
2 9
3 10
4 15
5 19
6 28
7 15
8 13
9 11
10 5
dataset b:
position count
1 4
2 8
3 16
4 17
5 19
6 10
Thanks a lot!
Jim
[[alternative HTML version deleted]]
2009 Sep 09
2
ggplot2: mixing colour and linetype in geom_line
...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_plot<-ggplot(THT_N2_ATGMS,aes(x=Temp)) +
# geom_line(aes(y=X22,colour="CO2")) +
# geom_line(aes(y=X44,colour="CO2")) +
geom_line(aes(y=X43,colour="AA",linetype="43")) +
geom_line(aes(y=X45,colour="AA",linetype="45"))
data set looks like:
Temp X22 X43 X44...
2018 Jul 18
2
Legendas en una gráfica de ggplot2
...-4, 4, by=0.01)
o=exp(t+1)/(1+(exp(t+1)))
### Con b igual a 0.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...
2007 Sep 03
1
Legend issue with ggplot2
...nd).
library(ggplot2)
dummy <- data.frame(x = rep(1:10, 4), group = gl(4, 10))
dummy$y <- dummy$x * rnorm(4)[dummy$group] + 5 * rnorm(4)[dummy$group]
dummy$min <- dummy$y - 5
dummy$max <- dummy$y + 5
ggplot(data = dummy, aes(x = x, max = max, min = min, fill = group)) +
geom_ribbon() + geom_line(aes(y = max, colour = fill)) + geom_line(aes(y
= min, colour = fill))
When I adjust the code to the line below, it works again. But this time
with two legend keys for "group". Any idea how to display only one
legend key for group? The ggplot-code aboved yielded only on legend key.
ggpl...
2008 Feb 12
3
problems plotting geom_line on ggplot2
Se ha borrado un texto insertado con un juego de caracteres sin especificar...
Nombre: no disponible
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20080212/16ba8b97/attachment.pl
2012 Dec 12
1
ggplot: geom_line with only pairs of points connected
...the
"connect" argument to be quite useful.
I've moved to ggplot for several reasons, but would still like to
connect lines conditionally, somehow.
Is it possible to do?
Small example:
df <- data.frame(cat=LETTERS[1:4],num=rnorm(4))
ggplot(df, aes(x=cat, y=num)) + geom_point() +
geom_line(aes(x=as.numeric(cat), y=num))
In this plot, I would like to be able to make the second line (the one
between B and C) not be there.
What I've come up with is this (instead using geom_segment):
df <- data.frame(cat=LETTERS[1:4],num=rnorm(4))
dfdf <-cbind(df[seq(from=1,by=2,along.with=...
2010 Nov 04
5
ggplot output
Dear All,
I have this script:
dat <- data.frame(Month = hstat$Date,C_avg = hstat$C.avg,C_stdev =
hstat$C.stdev)
ggplot(data = dat, aes(x = Month, y = C_avg, ymin = C_avg - C_stdev, ymax =
C_avg + C_stdev)) +
geom_point() +
geom_line() +
geom_errorbar()
dat <- data.frame(Month = hstat$Date,K_avg = hstat$K.avg,K_stdev =
hstat$K.stdev)
ggplot(data = dat, aes(x = Month, y = K_avg, ymin = K_avg - K_stdev, ymax =
K_avg + K_stdev)) +
geom_point() +
geom_line() +
geom_errorbar()
dat <- data.frame(Month = hstat$Dat...
2009 Sep 12
1
ggplot2: deterministic position_jitter & geom_line with position_jitter
...roup,position=position_jitter(w=0.1,h=0))
For x=1, the foo point is to the left of the bar point, and for x=3 the
other way around. I would like to have all foo points at
seq(1,3)-epsilon and all bar points at seq(1,3)+epsilon. Do I need to
manually modify example.data$x groupwise for this?
2) geom_line with position_jitter - when I call multiple geoms with
position_jitter, each geom gets its own jittering. For example
(continuing with example.data above):
set.seed(2009)
qplot(x,y,data=example.data,geom=c("point","line"),shape=group,position=position_jitter(w=0.1,h=0))
The...
2017 Oct 13
4
[FORGED] can't print ggplot with Chinese characters to pdf files
...it at the pdf file produced by ggsave.
> It gives an
> error message
>
>
>
> rm(list=ls())
> library(ggplot2)
> library(gridExtra)
> df1<-data.frame(x=1:2, y=3:4, z=5:6)
> #p1<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle("test1")
> #p2<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle("test2")
> p1<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle("??")
> #Chinese title
> p2<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle(&qu...
2008 Jan 23
1
Problem with geom_line
Se ha borrado un texto insertado con un juego de caracteres sin especificar...
Nombre: no disponible
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20080123/ab90f75d/attachment.pl
2010 Sep 16
1
plotting time series using ggplots
...distinct tree
ring series in each column. So, something like this:
rwl<-matrix(rnorm(800), nrow = 100)
colnames(rwl) <- paste('V', 1:8, sep = '')
rownames(rwl)<-c(1900:1999)
rwl<-as.data.frame(rwl))
I have 2 specific things I'd like to do:
1) use stat_summary(), geom_line(), and either geom_smooth() or
geom_ribbon() to plot the mean of the timeseries (e.g. V1:V8) and
error bands or confidence limits around the mean for each year. I
cannot figure out how to do this except for this really clunky way:
rwl$year<-as.numeric(rownames(rwl))
h<-ggplot(rwl, ae...
2017 Oct 13
1
[FORGED] can't print ggplot with Chinese characters to pdf files
...see the figures p1 and p2 on
> Studio, but I can't see it at the pdf file produced by ggsave. It gives an
> error message
>
>
>
> rm(list=ls())
> library(ggplot2)
> library(gridExtra)
> df1<-data.frame(x=1:2, y=3:4, z=5:6)
> #p1<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle("test1")
> #p2<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle("test2")
> p1<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle("??") #Chinese title
> p2<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle("??") #Chinese title
> p1&...
2017 Oct 12
2
can't print ggplot with Chinese characters to pdf files
...erfectly.
(2) If I use Chinese title, I can still see the figures p1 and p2 on
Studio, but I can't see it at the pdf file produced by ggsave. It gives an
error message
rm(list=ls())
library(ggplot2)
library(gridExtra)
df1<-data.frame(x=1:2, y=3:4, z=5:6)
#p1<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle("test1")
#p2<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle("test2")
p1<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle("??") #Chinese title
p2<-ggplot(df1, aes(x=x, y=y))+geom_line()+ggtitle("??") #Chinese title
p1<-p1+theme(text =...