Questions tagged [abline]

21 questions
6
votes
2 answers

Programmatically label multiple ablines in R ggplot2

There are existing questions asking about labeling a single geom_abline() in ggplot2: R ggplot2: Labelling a horizontal line on the y axis with a numeric value R ggplot2: Labeling a horizontal line without associating the label with a series Add…
Hendy
  • 10,182
  • 15
  • 65
  • 71
3
votes
2 answers

How to draw a horizontal line based on the values of "secondary Y axis" to intercept with the curve and then automatically draws a vertical line

I am trying to draw a plot in R. The resultant chart should be something like this: So far, I have written some codes and the main components of the chart has been created as shown below: But as you may noticed, the ideal plot (the upper plot) has…
Oscar
  • 79
  • 5
2
votes
1 answer

adding abline line with reverse secondary axis

I have the following data: data= structure(list(inv_kT = c(42.6123919742007, 42.4799809266797, 42.4722825012597, 42.4510843820046, 42.4193914112338, 42.4122074755519, 42.3764231025678, 42.3067291931282, 42.1980484435468, 42.1420505628077,…
yuliaUU
  • 1,581
  • 2
  • 12
  • 33
2
votes
2 answers

Changing color of columns above a certain value in barplot() in R

I am trying to create a barplot that illustrates the number of issue reports for certain issues in an 'imaginary' business. I have used abline() to add a line at a certain value and would like to change the color of the bar above this point. Is such…
1
vote
1 answer

How to calculate confidence bands for fitted values of a linear regression by hand and plot them?

I'm trying to plot error bands around a linear regression. I'm working with the builtin trees dataset in R. Here's my code. No lines are showing up on the plot. Please help! xdev <- log(Volume) - mean(log(Volume)) xdev ydev <- Girth -…
Ansley
  • 13
  • 2
1
vote
1 answer

Mean in Scatterplot not illustrated

I want to assign the means of x and y to a scatterplot in R without ggplot, just basic R. However, in the way I try (using abline), it does not illustrate the lines in the plot. I already had to do another task earlier, hence the slightly longer…
Apharlef
  • 25
  • 5
1
vote
1 answer

How do I make a regression line for all values of my variable?

My plot: plot(airbnb$distance_center,airbnb$price,pch=13,xlab="distance_center",ylab="price",bty="n") mod <- lm(price~number_people+distance_center) Now I want to include regression lines that show the correlation of price & distance_center -…
jfnotk
  • 15
  • 6
1
vote
2 answers

Plotly in R - Diagonal AB line

I require a diagonal line through the origin of this plot Something similar to ggplot2's geom_abline(intercept = 0 , slope = 1) But for plotly in R library(plotly) fig <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length) fig
Brad
  • 580
  • 4
  • 19
1
vote
1 answer

Abline command is not showing a regression line?

I'm new to R programming and I'm trying to plot a regression line for this data set, but it doesn't seem to be working. I followed exactly what my professor was using, however it doesn't seem to be working. I've also interchanged the abline command…
seashelbsy
  • 13
  • 2
1
vote
1 answer

abline() in zoo plot puts lines in wrong location

I saw here that abline() does not work with xts plots. I typically use plot(as.zoo()) of xts objects and ran into the following problem. Let's first generate some dummy time series data (the definition of start and end turn out to be…
Marius Hofert
  • 6,546
  • 10
  • 48
  • 102
1
vote
1 answer

Abline error in R for multiple regression with interaction variable

I want two different lines for men and women in the same plot but I always get non-sense lines when I run this code. What is the problem and how can I solve…
Tatanik501
  • 159
  • 10
1
vote
1 answer

restrict range of geom_abline(slope=somenumber)

I am trying to restrict the ranges of geom_abline. In the plot below, I would like the red line to stop at the xvalue 5 and the blue line to start at the value 5 (in the picture, I marked by hand the segments that need to be removed). obs: I…
LucasMation
  • 2,408
  • 2
  • 22
  • 45
0
votes
0 answers

Is it possible to create a 95% confidence interval around an abline using the basic plot function/ include a simple slope-intercept formula in ggplot?

I am running a Phylogenetic Generalized Least Squares (PGLS) model, and want to show the correlation when I correct for relatedness as a line on my graph. Because of this, I cannot use the normal geom_smooth() function in ggplot. The normal abline()…
0
votes
1 answer

Linear regression model incorrectly calculated in R

I have 3 different datasets that I have been plotting this way: Each dataset was imported from a file to a data frame (respectively called vues, likes and commentaires), and contains the date and the corresponding data (either views, likes or…
mi1000
  • 104
  • 9
0
votes
1 answer

Plotting adjusted regression with least squares

I have a regression model fitted with least squares. library(TSA) data(hours) lmhr2 <- lm(hours ~ time(hours)+ I(time(hours)^2), data =hours) summary(lmhr2) plot(hours) abline(lmhr2) When I run abline to the plot, I get this error: In…
Nana
  • 13
  • 4
1
2