Questions tagged [geom-vline]

59 questions
1
vote
1 answer

ggplot geom vline between two dates on x axis

Is there any way to place geomvline between two dates on x axis. For example like red line in below picture. My data is something like this below where can be dynamic in length. df <- data.frame(Date= seq(as.Date("2019-01-11"),…
aprilian
  • 621
  • 3
  • 17
1
vote
1 answer

how to add multiple vline on an histogram using ggplot2

I have plotted an histogram has shown Histogram I want to add vertical lines when the sum of the probability of the allocation imbalance is 50%, 80% and 90%. I have constructed the histogram but I am unable to add the vertical lines described…
Jackline
  • 59
  • 1
  • 9
1
vote
0 answers

Add geom_vline legend with existing geom_line legend

I have a problem adding geom_vline legends when I already have very well defined geom_line legends my code is as follows: g1=ggplot(M7, aes(x =CODT, y =TNA, group =Tre7)) g1=g1+geom_line(aes(color=Tre7, linetype=Tre7),…
Kota
  • 11
  • 1
0
votes
2 answers

Error: object 'i' not found in geom_hline and geom_vline

I want to make a scatter plot with a horizontal and a vertical line. The lines shall appear at the mean of the x and y variable. What I do is: # Some data df <- data.frame(x= rnorm(100), y= rnorm(100)) df$i1 <- mean(df$x) df$i2 <- mean(df$y) #…
LulY
  • 976
  • 1
  • 9
  • 24
0
votes
0 answers

Color dataset by group and add geom_vline to legend only

I have a genome-wide dataset that I'm trying to plot in the following way: Have each chromosome be a separate color Have specific windows highlighted by a bar (I'm using geom_vline) - this I'm getting from a separate table Have only geom_vline…
Rachel
  • 73
  • 7
0
votes
1 answer

How to put geom_vline manually in ggplot legend (r)

I want to make a plot with a vertical line to represent the beggining of a policy. How can I add this vertical line to the legend of the plot? example: df <- tibble(year = 2010:2014, value = c(1,2,3,3,4)) df %>% ggplot(aes(x = year, y =…
uow
  • 120
  • 7
0
votes
0 answers

How to create a different vline for 3 conditions?

I am trying to get a vline on a predicted plot until the sjplot::plot_model function. I have a paneled graph and for each condition (baseline, autonomous and fairness) I have a different vline I want to depict. Basically the point of divergence when…
G.T.G.
  • 1
0
votes
1 answer

When geom_vline is used, meridional lines cannot extend to the border of the figure under a non-WGS 84 projection

I want the grid lines to be displayed on top of the picture, so I tried to use geom_hline/geom_vline to do this, but it turned out that the vertical lines do not extend to the northern border of the picture. Is there anything I can do to…
Li Yupeng
  • 721
  • 4
  • 9
0
votes
1 answer

ggplot - multiple different geom_vlines with differing lengths

I am trying to emulate the image shown where the vertical lines stop at the data points. Is there a way to give geom_vlines a specific length? I have included example code below to show what I have right now. I want each vline to stop when it…
Indescribled
  • 320
  • 1
  • 10
0
votes
1 answer

Referring to the input data of ggplot and use that in a custom function within a geom

I'm using ggplot geom_vline in combination with a custom function to plot certain values on top of a histogram. The example function below e.g. returns a vector of three values (the mean and x sds below or above the mean). I can now plot these…
Rasul89
  • 588
  • 2
  • 5
  • 14
0
votes
1 answer

Adjust color of geom_vline in ggplot based on group

So I am creating density plot for Sepal.Length for two species of the iris-dataset. The graph looks like this: As you can see, I added two measures of central tendency to the graph (Median and Mean). However, right now they are colored depending on…
Maximilian
  • 89
  • 1
  • 7
0
votes
1 answer

How to add legened to geom_vline?

I have a dataframe (df_new) that looks something like this: date<- c("2020-01-01", "2020-01-02", "2020-01-03", "2020-01-04", "2020-01-05") A <- c(23, 41, 32, 58, 26) B <- c(10, 20, 30, 40, 50) df_new <- data.frame(date, A, B) df_new$date <-…
AneesBaqir
  • 423
  • 1
  • 12
0
votes
1 answer

Both geom_vline and geom_hline fails when faceting spatial map on ggplot2

I am really careful before posting this this question, in order to avoid any duplication. So I intended to create a faceting map based on quarter, equipped with both major and minor grid, whereas the latitude and longitude labels only on major grid.…
0
votes
1 answer

I already have 'color' and 'fill' legends. How can I control the colour of a line produced using geom_vline?

I'm trying to product a bar plot and line plot on the same axes, with a rectangle to show where data may be incomplete and vertical lines showing important dates. library(dplyr) library(ggplot2) library(scales) dates <-…
joewozza
  • 57
  • 5
0
votes
0 answers

How can I add a geom_vline of certain dates to my plot if those dates are not present in my original dataset?

The gist of what I am trying to do is to overlay dates in which lockdowns came into place and the dates on which they ended. My data contains weekly sales figures but does not contain the dates in which the lockodwns started or ended, thus when I…
Petru
  • 1
  • 2