search for: geom_abline

Displaying 20 results from an estimated 36 matches for "geom_abline".

2007 Nov 08
1
ggplot2 geom_abline slope not working?
I am learning ggplot2, and need your help. When I try > p <- ggplot(mtcars, aes(x = wt, y=mpg)) + geom_point() > p + geom_abline(slope=5) (from http://had.co.nz/ggplot2/geom_abline.html) the slope of the abline does not change, but this works: > p + geom_abline(intercept=20) In order to have slope work, I have to use > p + geom_abline(aes(slope=5)) Is it a bug, or is there some reason slope and intercept were tre...
2007 Oct 03
1
ggplot2: problem with geom_errorbar and geom_abline
Hi all, I have run into what appears to be a bug in ggplot2; however, I am new to the ggplot syntax, so I might be missing a key element. The main issue is that I cannot get geom_abline to plot when colour is used to identify "group" in the main plot. When I remove colour, geom_abline works but the error bars have an undesirable line drawn between the left edges of the caps. Does anyone know how to change this behavior? I am using R version 2.5.1 and ggplot2 version...
2013 Nov 12
0
geom_abline does not seem to respect groups in facet_grid [ggplot2]
Just trying to understand how geom_abline works with facets in ggplot. By way of example, I have a dataset of student test scores. These are in a data table dt with 4 columns: student: unique student ID cohort: grouping factor for students (A, B, . H) subject: subject of the test (English, Math, Science) score: the test score fo...
2020 Oct 23
5
How to shade area between lines in ggplot2
...p = ggplot(data = trainset, aes(x=x, y=y, color=z)) + geom_point() + scale_color_manual(values = c("red", "blue")) # show decision boundaries w = t(svm_model$coefs) %*% svm_model$SV # %*% = matrix multiplication slope_1 = -w[1]/w[2] intercept_1 = svm_model$rho / w[2] p = p + geom_abline(slope = slope_1, intercept = intercept_1) ### here we go: can I use a shaded area between these two lines? ### p = p + geom_abline(slope = slope_1, intercept = intercept_1 - 1/w[2], linetype = "dashed") + geom_abline(slope = slope_1, intercept = intercept_1 + 1/w[2],...
2020 Oct 23
2
How to shade area between lines in ggplot2
Thank you, but this split the area into two and distorts the shape of the plot. (compared to ``` p + geom_abline(slope = slope_1, intercept = intercept_1 - 1/w[2], linetype = "dashed", col = "royalblue") + geom_abline(slope = slope_1, intercept = intercept_1 + 1/w[2], linetype = "dashed", col = "royalblue") ``` Why there is a hole in...
2020 Oct 23
0
How to shade area between lines in ggplot2
...es(x=x, y=y, color=z)) + > geom_point() + scale_color_manual(values = c("red", "blue")) # show > decision boundaries w = t(svm_model$coefs) %*% svm_model$SV # %*% = > matrix multiplication > slope_1 = -w[1]/w[2] > intercept_1 = svm_model$rho / w[2] > p = p + geom_abline(slope = slope_1, intercept = intercept_1) ### here we go: > can I use a shaded area between these two lines? ### p = p + > geom_abline(slope = slope_1, intercept = intercept_1 - 1/w[2], > linetype = "dashed") + > geom_abline(slope = slope_1, intercept = i...
2020 Oct 23
2
How to shade area between lines in ggplot2
...eom_point(data = df_sv, aes(x=x, y=y), color="purple", size=4, alpha=0.5) # show hyperplane (decision boundaries are off set by 1/w[2]) w = t(svm_model$coefs) %*% svm_model$SV # %*% = matrix multiplication slope_1 = -w[1]/w[2] intercept_1 = svm_model$rho / w[2] p = p + geom_abline(slope = slope_1, intercept = intercept_1, col = "royalblue4") p = p + geom_ribbon(aes(ymin=intercept_1 - 1/w[2], ymax=intercept_1 + 1/w[2], x=x, fill = "band"), alpha = 0.3) + scale_fill_manual("",values=&qu...
2020 Oct 26
0
How to shade area between lines in ggplot2
...20 3:30 PM > To: PIKAL Petr <petr.pikal at precheza.cz> > Cc: r-help <r-help at r-project.org> > Subject: Re: [R] How to shade area between lines in ggplot2 > > Thank you, but this split the area into two and distorts the shape of the > plot. > (compared to ``` p + geom_abline(slope = slope_1, intercept = intercept_1 - > 1/w[2], > linetype = "dashed", col = "royalblue") + > geom_abline(slope = slope_1, intercept = intercept_1 + 1/w[2], > linetype = "dashed", col = "royalblue") ``` &gt...
2020 Oct 23
0
How to shade area between lines in ggplot2
...), > color="purple", size=4, alpha=0.5) # show hyperplane > (decision > boundaries are off set by 1/w[2]) w = t(svm_model$coefs) %*% > svm_model$SV # %*% = matrix multiplication > slope_1 = -w[1]/w[2] > intercept_1 = svm_model$rho / w[2] > p = p + geom_abline(slope = slope_1, intercept = intercept_1, col = > "royalblue4") > p = p + geom_ribbon(aes(ymin=intercept_1 - 1/w[2], > ymax=intercept_1 + 1/w[2], > x=x, fill = "band"), alpha = 0.3) + > scale_fill_manua...
2010 Apr 23
1
ggplot2: how to specify x-axis limits to geom_abline() ?
Hi all, I'd want to plot a segment from a line specified by slope and intercept. I want to plot this line between two limits, x1 and x2, without imposing these limits to the hole plot as it is the case with scale_x_continuous(limits=c(x1,x2)) or with xlim and ylim. Any idea? Arnaud Chozo [[alternative HTML version deleted]]
2011 Jul 10
2
grey colored lines and overwriting labels i qqplot2
...', labels='label A')+ scale_colour_hue(breaks='B', labels='label B') 3.) I would like to add the lines so it matches the default grey scale (graph 2), but I do not know the name of the different shades in the grey scale. I added the lines in the following way: > p + geom_abline(intercept = 81.476, slope=47.267, colour = "green", size = > 1, subset = .(country == 'low'))+ geom_abline(intercept = 31.809, > slope=20.234, colour = "blue", size = 1, subset = .(country == 'low')) > +..... http://r.789695.n4.nabble.com/file/n3657119/...
2009 Jan 29
2
Adding vertical line to histogram and qplot "stacked" plot
...ataframe, breaks = breaks, fill = Temperature, main = short_title) + scale_x_continuous("Data") + scale_y_continuous("Freq") +  scale_fill_discrete("Temperature") + scale_fill_manual(values = c(LOW = "blue", AMB ="black", HIGH = "red")) +  geom_abline(v = HighVal, col = "dodgerblue3", lty="dotdash")     "hist" approach attempt: hist(data_dataframe, breaks = breaks,  col = "dodgerblue3", xlab="Data", freq = TRUE, main="") +abline(v = HighVal, col = "dodgerblue3", lty="dot...
2011 Jun 26
1
changing graphs in qqplot2
...acet wraps that the line belongs to, as it turns up in both grids. Is that possible in qqplot2? > p=ggplot(data = test, aes(x = YEAR, y = TOTAL, colour = TREATMENT)) + > geom_point() + facet_wrap(~NITROGEN) #this is the treatment A, but should only be displayed in the right graph (low). p + geom_abline(intercept = 81.476,slope=47.2667, colour = "red", size = 1) http://r.789695.n4.nabble.com/file/n3626510/graph2.gif b. Another option I?ve tried is to specify the model in the stat_smooth and geom_smooth commandsm=, but in both cases I get an error message. > p + stat_smooth(metho...
2007 Jul 24
1
ggplot2 axis color
Hi: Does anyone have an idea on how to color the axis and labels using ggplot2? This is what I got: library(ggplot2) p <- qplot(total_bill, tip, data = tips) NewPlot<- p + geom_abline(slope=c(0.1,0.15,0.2), colour=c("red","blue","yellow"),size=c(2,5,2)) NewPlot + geom_smooth(colour="green", size=3,linetype=3) NewPlot$background.fill<-"cornsilk" NewPlot$background.colour <- "blue" NewPlot$axis.colour<-"red...
2007 May 13
1
adding custom details to ggplot subplots
? stato filtrato un testo allegato il cui set di caratteri non era indicato... Nome: non disponibile Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070513/ab60c7ed/attachment.pl
2023 May 16
1
Newbie: Drawing fitted lines on subset of data
...t example to test segments: w <- tsibble( date = as.Date("2022-01-01") + 0:99, value = rnorm(100) ) ggplot(data = w, mapping = aes(date, value)) + geom_smooth(method = "lm", se = FALSE) + geom_point() ## Below gives error about ignoring data ## geom_abline( data = w$date[25:75] ) ## Gives error ''data' must be in <data.frame>' ## geom_smooth(data = w$date[25:35], ## method = lm, ## color = "black", ## se = FALSE) I'm thinking that this is probably easily...
2011 Dec 23
1
simple ggplot2 question
...would do the trick. I also tried converting variable place into class 'factor'. require(ggplot2) DF <- data.frame(place=letters, value=runif(26), location=c(rep(1, 13), rep(0, 13))) qplot(data=DF, x=place, y=value, geom="bar", stat="identity") +   coord_flip() +   geom_abline(intercept=35, slope=0, colour="red") +   facet_grid(location ~ ., scales="free_y") R.version.string # "R version 2.10.1 (2009-12-14)" Thank you in advance & merry xmas!   Cheers!! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
2011 Sep 07
1
linear regression, log-transformation and plotting
...transformation at all) Then some questions arise when it comes to plot the data. As usual I'd like to plot the original data (not log transformed) but in a log-scale. I tried two approaches the standard plot function and ggplot. # Plot with ggplot ggplot()+ geom_point(aes(b1,a1,data=data1))+ geom_abline(aes(intercept=coef(model)[1],slope=coef(model)[2]))+ scale_y_log()+ scale_x_log() # Plot with standard plot plot(b1,a1,log="xy") abline(model,untf=T) abline(model,untf=F) 1) The regression lines are different for plot vs. ggplot(transformed or untransformed). So what is actually the co...
2008 Apr 04
0
ggplot2 - version 0.6
...e legend code is now considerably more sophisticated and will attempt to merge together legends for the same variable * also, legends are drawn based on the geoms used (instead of the scales used, as previously) so should match the plot much better (e.g. for geom_smooth, geom_boxplot, geom_vline, geom_abline, geom_pointrange). These features are new, so there are likely to be a few bugs that I haven't discovered. Please me know if you do find any. Other additions and corrections * coord_equal: should now work correctly in all situations * coord_polar: add start and direction parameters, giv...
2008 Apr 04
0
ggplot2 - version 0.6
...e legend code is now considerably more sophisticated and will attempt to merge together legends for the same variable * also, legends are drawn based on the geoms used (instead of the scales used, as previously) so should match the plot much better (e.g. for geom_smooth, geom_boxplot, geom_vline, geom_abline, geom_pointrange). These features are new, so there are likely to be a few bugs that I haven't discovered. Please me know if you do find any. Other additions and corrections * coord_equal: should now work correctly in all situations * coord_polar: add start and direction parameters, giv...