search for: ggplot_build

Displaying 10 results from an estimated 10 matches for "ggplot_build".

2023 Aug 12
1
geom_smooth
...e, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. Hello, Here is a solution. You ,ust access the computed variables, which you can with ?ggplot_build. Then pass them in the data argument. p <- ggplot(scatter_data,aes(x=x_var,y=y_var)) + geom_point()+ geom_smooth(se=TRUE,fill="blue",color="black",linetype="dashed")+ theme_cowplot() # this is a data.frame, relevant columns are x, ymin and ymax fit &lt...
2023 Aug 12
2
geom_smooth
Colleagues, Here is my reproducible code for a graph using geom_smooth 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")+
2014 Jun 20
1
zuzufarah Help with ggplot 2 error: Aesthetics must either be length one, or the same length as the dataProblems
...table) + .1*diff(range(WUA_table)))) + expand_limits(x = c(min(WUA_discharge) - .1*diff(range(WUA_discharge)), max(WUA_discharge) + .1*diff(range(WUA_discharge)))) + theme(plot.margin= unit(c(0, 0, 0.5, 0.5), "lines")) # Get the gtables gt1 <- ggplot_gtable(ggplot_build(p1)) the error message from the following code states: Error: Aesthetics must either be length one, or the same length as the dataProblems:WUA_table the error appears after the line: gt1 <- ggplot_gtable(ggplot_build(p1)) I would appreciate some help on the matter, it seems like a small fix,...
2012 Aug 07
1
Styling gridExtra's title and left labels
...l the style / size of the gridExtra labels? library(gridExtra) library(ggplot2) dsamp <- diamonds[sample(nrow(diamonds), 1000), ] p1 <- qplot(carat, price, data=dsamp, colour=clarity) p2 <- qplot(carat, price, data=dsamp, colour=clarity, geom="path") tmp <- ggplot_gtable(ggplot_build(p1)) leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box") legend <- tmp$grobs[[leg]] grid.arrange(arrangeGrob(p1 + theme(legend.position="none") + ggtitle("Scatter Plot"), p2 + theme(legend.position="non...
2016 Apr 18
0
Add a vertical arrow to a time series graph using ggplot and xts
...uot;2016-01-01"), as.Date("2016-01-10"), by = "1 day")) colnames(dt_xts)<-"gdp" xmin<-min(index(dt_xts)) xmax<-max(index(dt_xts)) df1<-data.frame(x = index(dt_xts), coredata(dt_xts)) p<-ggplot(data = df1, mapping= aes(x=x, y=gdp))+geom_line() rg<-ggplot_build(p)$panel$ranges[[1]]$y.range y1<-rg[1] y2<-rg[2] df2<-data.frame(x = "2016-01-05", y1=y1, y2=y2 ) p1<-p+geom_segment(mapping=aes(x=x, y=y1, xend=x, yend=y2), data=df2, arrow=arrow()) [[alternative HTML version deleted]]
2016 Apr 20
0
Add a vertical arrow to a time series graph using ggplot and xts
...as.Date("2016-01-10"), by = "1 day")) colnames(dt_xts)<-"gdp" xmin<-min(index(dt_xts)) xmax<-max(index(dt_xts)) df1<-data.frame(x = index(dt_xts), coredata(dt_xts)) p<-ggplot(data = df1, mapping= aes(x=x, y=gdp))+geom_line() rg<-ggplot_build(p)$panel$ranges[[1]]$y.range y1<-rg[1] y2<-rg[2] # x = as.Date(..) in place of x = "2016-01-05" df2<-data.frame(x = as.Date("2016-01-05"), y1=y1, y2=y2 ) p1<-p+geom_segment(mapping=aes(x=x, y=y1, xend=x, yend=y2), data=df2, arrow=arrow()) -- Be...
2014 Jan 19
2
stat_density2d de ggplot2
Hola comunidad, tengo el siguiente problema con la funcion stat_density2d (estimacion de densidad 2d.) del paquete ggplot2 stat_density2d (mapping = NULL, data = NULL, geom = "density2d", position = "identity", na.rm = FALSE, contour = TRUE, n = 100, ...) de esta función requiero ver el cálculo númerico de la estimación de la densidad, cuento con el siguiente codigo y
2013 Jul 18
1
Bland Altman summary stats for all column combinations
...=element_blank()) + ggtitle(x1$Method) + theme(plot.title = element_text(lineheight=1,face="bold")) + geom_text(data = subset(melt(cor(x1[sapply(x1,is.numeric)])),Var1==Var2),aes(label=Var1),vjust=3 ) }) #Function to grab legend g_legend<-function(a.gplot){ tmp <- ggplot_gtable(ggplot_build(a.gplot)) leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box") legend <- tmp$grobs[[leg]] legend } legend <- g_legend(plots$WIG_Method) grid.arrange(legend,plots$Single_ROI+theme(legend.position='none'), plots$Simple_2_ROI+theme(legend.position...
2012 Mar 02
0
ggplot2 0.9.0
...n capture this with (e.g.) `x <- print(qplot(mpg, wt, data = mtcars))` and in the future will be able to use it to get information about the plot computations, such as the range of all the scales, and the exact data that is plotted. * Drawing a plot takes place in three documented steps: `ggplot_build` which creates a list of data frames ready for rendering builds, `ggplot_gtable` which creates a `gtable` of grobs, and `grid.draw` which renders the grobs on screen. Each of these returns a data structure which should be useful for understanding and modifying the rendered plot. This is sti...
2012 Mar 02
0
ggplot2 0.9.0
...n capture this with (e.g.) `x <- print(qplot(mpg, wt, data = mtcars))` and in the future will be able to use it to get information about the plot computations, such as the range of all the scales, and the exact data that is plotted. * Drawing a plot takes place in three documented steps: `ggplot_build` which creates a list of data frames ready for rendering builds, `ggplot_gtable` which creates a `gtable` of grobs, and `grid.draw` which renders the grobs on screen. Each of these returns a data structure which should be useful for understanding and modifying the rendered plot. This is sti...