PhDMeiwp / ggtrendline

ggtrendline: An R Package for Adding Trendline and Confidence Interval to 'ggplot'.
https://CRAN.R-project.org/package=ggtrendline
25 stars 1 forks source link

Changing axis scale and adding headings in ggtrendlines #4

Open PLCunningham opened 2 years ago

PLCunningham commented 2 years ago

How does one change the axis scales and add a heading when the normal x/ylim and main functions do not work? Also how do you move or remove the y, r^2 or p values that automatically appear in the top left area of the plot?

PhDMeiwp commented 2 years ago

Dear PLCunningham,

Thanks for your issue.

Q1: How to change the axis scales and add a heading? A1: Using 'ggtendline' package together with 'ggplot2' package, the 'xlim', 'ylim', and 'ggtitle' functions in ggplot2 worked, for example:

library(ggplot2)  #Loading ggplot2 package first
library(ggtrendline)
x <- c(1, 3, 6, 9,  13,   17)
y <- c(5, 8, 11, 13, 13.2, 13.5)
ggtrendline(x, y,  "exp2P") + xlim(0, 20) + ylim(0, 30) + ggtitle("Add a heading using 'ggplot2' package")

Rplot01

Q2: How to move or remove the y, r^2 or p values? A2: For move, using 'eq.x', 'eq.y', 'rrp.x', and 'rrp.y' functions in our 'ggtrendline' package; and for remove, using 'show.eq', 'show.Rsquare' and 'show.pvalue' in our 'ggtrendline' package.

library(ggtrendline)
x <- c(1, 3, 6, 9,  13,   17)
y <- c(5, 8, 11, 13, 13.2, 13.5)
ggtrendline(x,y, "exp2P", eq.x = 9, eq.y = 18, rrp.x = 9, rrp.y = 16, eSize = 5)

Rplot02

BTW, you can type ??ggtrendline to see all Arguments built in our 'ggtrendline' package.

Best regards, Mei