ggplot(floyd, aes(factor(Round), Opp. I've switched to ggplot, as I don't know the ins and outs of qplot. This will automatically add a regression line for y x to the plot. I'm not exactly sure how you want the legends and other details to look, so let me know if this works. UPDATE: Here's my attempt using the data you provided. Marker numbers 21 through 25 are filled (see ?pch for more on point markers). Otherwise, your point markers will disappear along with the lines. If you have points that are tied to the color aesthetic as well, then you'll need to change the points to a fill aesthetic (e.g., fill=Opponent) and use a filled point marker that you can set manually using shape or pch. For example, if the category you want to highlight is the second category and you have a total of five categories, then add this to your plot code: scale_colour_manual(values=c(NA, "red", rep(NA,3))) Regression lines can be added as follow: Add regression lines ggplot(mtcars, aes(xwt, ympg. I can't give a tailored answer without being able to run your code on a sample of your data, but you can use scale_color_manual to set the colour of the category you want to highlight to, say, "red" and set all the others to NA. I just want any one of these to have connected points: ![]() Please see the sample dataset from with three categories. We can change the size of scatter plot with size argument inside geompoint() and change the color of the connecting to lines to grey so that we can clearly see the data and. Let us further customize the scatterplot with connected lines. Any ideas? I've tried adding geom_line(aes(linetype=floyd), size=1) but it errors out with Error in [.ame`(floyd, Opponent = "Manny Pacquiao") : unused argument (Opponent = "Manny Pacquiao")ĮDIT: I've updated the code above to exclude ftheme so it's reproducable. Scatterplot Connecting Paired Points with lines ggplot2 Customizing the lines connecting paired data points. The ftheme code is just colors and formatting. Guides(colour = guide_legend(override.aes = list(size=5))) Scale_linetype_manual(values=1:2, labels=c("Boxer", "Connect Percentage")) + ![]() Labs(x="Round", y="Punches Landed", title="Opponent Punches Landed / Percentage", colour="Boxer", size="Connect Percentage") + Let us regress mpg over disp and then use the result to add the line. Qplot(factor(Round), Opp.Landed, data=floyd, color=Opponent, size=, alpha = I(0.7)) + If you know the intercept and the slope of the line, you can use geomabline(). I want one of these categories to have a line connecting the dots to highlight this category's data. I have a scatterplot that breaks the points out into different colors by the category. Method 1: Plot Line of Best Fit in Base R create scatter plot of x vs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |