similar to: How to use geom_line (from ggplot) with aesthetics in a function?

Displaying 20 results from an estimated 5000 matches similar to: "How to use geom_line (from ggplot) with aesthetics in a function?"

2014 Jun 20
1
zuzufarah Help with ggplot 2 error: Aesthetics must either be length one, or the same length as the dataProblems
WUA_table<-WUA.df[,2:dim(WUA.df)[2]] WUA_discharge<-WUA.df[,1] colour_scheme<-palette(rainbow(dim(WUA_table)[2])) # Main scatterplot p1 <- ggplot(NULL, aes(WUA_discharge,WUA_table)) + geom_line() + scale_color_manual(values=colour_scheme)+ scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0)) + expand_limits(y = c(min(WUA_table) -
2009 Apr 23
1
ggplot2/aesthetic plotting advice
Consider the following situation: we have quantified algal concentrations for a variety of species using many samples at each of three years. It seems to make sense to generate a line plot (matplot-like), with each species plotted as a separate line, with the points connected to emphasize the temporal pattern. The problem: lots of overlapping error bars. The question: from both a
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+ 30000 50 25 32")> data =
2012 Dec 12
1
ggplot: geom_line with only pairs of points connected
Dear list, I've been using plotmeans {gplots} a lot before, and found 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() +
2016 Apr 20
0
Add a vertical arrow to a time series graph using ggplot and xts
Please see updates to df2 assignment as shown below. library(xts) # primary #library(tseries) # Unit root tests library(ggplot2) library(vars) library(grid) dt_xts<-xts(x = 1:10, order.by = seq(as.Date("2016-01-01"), as.Date("2016-01-10"), by = "1 day")) colnames(dt_xts)<-"gdp" xmin<-min(index(dt_xts))
2009 Dec 11
0
ggplot2: version 0.8.4
ggplot2 ------------------------------------------------------------ ggplot2 is a plotting system for R, based on the grammar of graphics, which tries to take the good parts of base and lattice graphics and avoid bad parts. It takes care of many of the fiddly details that make plotting a hassle (like drawing legends) as well as providing a powerful model of graphics that makes it easy to produce
2009 Dec 11
0
ggplot2: version 0.8.4
ggplot2 ------------------------------------------------------------ ggplot2 is a plotting system for R, based on the grammar of graphics, which tries to take the good parts of base and lattice graphics and avoid bad parts. It takes care of many of the fiddly details that make plotting a hassle (like drawing legends) as well as providing a powerful model of graphics that makes it easy to produce
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
2013 Nov 04
1
ggplot2: Add '+' operator for aes (uneval) objects
Dear all, Is there a reason, why there is no +-operator for aes (i.e. uneval) objects (as there is for themes and gg objects)? I had a couple of cases where such an operator would be useful, for instance to combine the result of aes and aes_string in functions. Any flaws with the following proposition: `+.uneval` <- function(e1, e2) { dup <- names(e1) %in% names(e2) if (any(dup)) {
2011 Aug 15
1
ggplot in a function confusion!
Whats going on here? df<-data.frame(x=1:10,y=1:10) ggplot()+geom_point(data=df,aes(x=x,y=y)) ## this is the normal usage right? ggplot()+geom_point(data=df,aes(x=df[,1],y=df[,2])) ## but I can also feed it column indices ggplot()+geom_point(aes(x=df[,'x'],y=df[,'y'])) ## or column names. ## but if i wrap it in a function... plot.func.one<-function(dff,x.var,y.var){
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
2009 Sep 12
1
ggplot2: deterministic position_jitter & geom_line with position_jitter
Dear guRus, I am starting to work with the ggplot2 package and have two very dumb questions: 1) deterministic position_jitter - the jittering is stochastic; is there any way to get a deterministic jittering? For instance: example.data <- data.frame(group=c("foo","bar","foo","bar","foo","bar"),x=c(1,1,2,2,3,3),y=c(1,1,0,2,1,1))
2007 Sep 02
0
ggplot2 - version 0.5.5
ggplot2 =================================== ggplot2 is a plotting system for R, based on the grammar of graphics, which tries to take the good parts of base and lattice graphics and avoid bad parts. It takes care of many of the fiddly details that make plotting a hassle (like drawing legends) as well as providing a powerful model of graphics that makes it easy to produce complex multi-layered
2007 Sep 02
0
ggplot2 - version 0.5.5
ggplot2 =================================== ggplot2 is a plotting system for R, based on the grammar of graphics, which tries to take the good parts of base and lattice graphics and avoid bad parts. It takes care of many of the fiddly details that make plotting a hassle (like drawing legends) as well as providing a powerful model of graphics that makes it easy to produce complex multi-layered
2012 Sep 25
1
geom_line: How to plot two data sets having different maximum X-axis values in a single plot?
Hello, I just started 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
2008 Feb 15
1
ggplot2 used in a function - variable scope/environment
Hi everybody! I'm trying to use ggplot2 to return a plot from a function (so I can add something or alter it then). Unfortunately, if I add a mapping to a layer in the function, the variable *name* is stored in the layer, rather than the variable's *value* - so that after the function returns the ggplot2-object, it doesn't plot because the variable don't exist in the
2013 Jul 25
1
GGplot 2 – cannot get histogram and box plot axis to match.
Problem: I am trying to get the histogram and box plot x axis to match. I?ve tried using the expand_limits function to make the axis match but that didn?t make the axis match. The histogram?s axis are still consistently larger than the ones for the box plot (though the function did help). Does anyone have a suggestion as to what I should do instead? Background: I am building a Shiny app that
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 +
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",
2008 Sep 25
1
ggplot: adding layer using different data, groups and also controlling appearance
I have a more complicated function I am trying to write, but I run in to a problem when I want to add something to the plot from more than one data set while simultaneously controlling the appearance of the additional layer. # Toy data: foo <- data.frame ( x = 1:4, y = 4:1 , membership = c( "A", "A", "B", "B" ) ) bar <- data.frame ( x = 1:4 + 1 , y