Questions tagged [geom-vline]
59 questions
2
votes
1 answer
Having geom_vline() get along well with facet_grid(): a failed mapping example
Using the data generated from here, I would like to have ggplot2 create a plot similar to the one below.
Desirable plot panels with undesirable labeling (facet_wrap):
The objective in this plot is to allow visual comparison between the mean of the…

AlirezaAY
- 23
- 4
2
votes
1 answer
geom_vline, legend and performance
I want to plot a few vertical lines on my plot and have a legend for each corresponding vline.
After reading this post, here is what I implemented:
set.seed(99)
df.size <- 1e6
my.df <- data.frame(dist = rnorm(df.size, mean = 0, sd =…

Ben
- 6,321
- 9
- 40
- 76
1
vote
0 answers
Rmarkdown, ggplotly + flexdashboard: problems with geom_vline
I'm designing an flexdashboard output using ggplotly with geom_vline. With the next code, I can view the plot as I need:
library(openair)
library(tidyverse)
library(plotly)
aq <- importAURN(site = c("my1", "nott"), year = 2000,
…

Camilo Montes
- 21
- 3
1
vote
1 answer
Adding geom_vline for eventdate after filtering for ID adds vlines for every IDs eventdate
Im having a large dataset with repeated measurements in long format for several IDs. It contains measurments of patients. Every measurement is recorded to a timepoint as well as a date which is stored in date variable. In addition I record whether…

Max
- 91
- 7
1
vote
1 answer
Dynamic vlines and annotations on ggplot
I was wondering if it's possible to dynamically generate geom_vlines and annotations for a ggplot based on the contents of another dataframe.
I currently have a dataframe of the following structure, which I use to plot a time-series:
$ Date : Date,…

alec22
- 735
- 2
- 12
1
vote
2 answers
Geom_vline not showing grouped lines in stacked scatter plots in ggplot
So I have a set of data (df) where there are some values a1, a2, and a3 generated by date and by group (b1, b2, b3). I want to stack these scatterplots on each other and facet wrap by group (seems to work). a1, a2 and a3 should be 3 different…

SqueakyBeak
- 366
- 4
- 15
1
vote
1 answer
Make dotted geom_vline on legend
I'm trying to make a legend for a series of plots. I only need the legend, not the actual graphs as I am creating them separately and have the correct formatting for these already. I will then add this universal legend.
Currently I have the code for…

Melanie Baker
- 449
- 1
- 13
1
vote
1 answer
How to add a label to the x / y axis whenever a vertical / horizontal line is added to a ggplot?
The x and y axis are labeled based on certain interval set by ggplot.
In the event that a horizontal or vertical line is added to the plot, the goal is to label x or y axis at the exact value of the line.
How can this be done?

Bear Bile Farming is Torture
- 4,317
- 4
- 27
- 61
1
vote
2 answers
How to apply a continous color ramp to a straight line in ggplot2?
I have would like to apply a continous color ramp to a vertical line in ggplot2. My plot is below. I have applied the continous color ramp to the geom_line() element, while the horizontal lines represent the limits of the range covered by the color…

ia200
- 255
- 1
- 9
1
vote
1 answer
How to label vLines in ggplot (R)
I've created a stream plot from a time series and need 2 vertical line labelled with text "ignite" and "extinguish" repectively.
Given that it's a time series I'm having real problems getting the labels to display.
Here's the ggplot code thus…

Paul Smith
- 11
- 2
1
vote
1 answer
ggplot with both `geom_vline` and `geom_hline`. Task: need separate legends
library(tidyverse)
library(lubridate)
y <- rnorm(100)
df <- tibble(y) %>%
mutate(os = factor(rep_len(1:5, 100)),
date = seq(from = ymd('2013-01-01'), by = 1, length.out = 100))
ggplot(df, aes(x = date, y = y, colour = os)) +
…

Bear Bile Farming is Torture
- 4,317
- 4
- 27
- 61
1
vote
2 answers
Creating graphs in a loop: one graph different from the others
I have an elaborate code to create a series of graphs. I would like to put a vertical line in one of the many graphs I create.
Consider the following simple code:
library(ggplot2)
library(grid)
library(gridExtra)
plots <- list()
for (i in 1:4) {
…

Stata_user
- 562
- 3
- 14
1
vote
0 answers
R adding dynamic reference line to ggplot
I tried to use the solution mentioned in this Add vline to existing plot and have it appear in ggplot2 legend?
However, part of the code doesn't work for my case especially the vline part didn't work. I'm wondering if there are others trick?
I…

ponyhd
- 491
- 1
- 4
- 19
1
vote
1 answer
Plotting vertical/horizontal lines that intersect line graph on ggplot
The following code produces the following plot:
time_step <- c(1:5, 1:5)
perceived_signal_slow <- c(1:5, cumsum(1:5))
signal_name <-…

codegoblin1996
- 302
- 2
- 12
1
vote
2 answers
ggplot geom_vline with binary variable and x-axis dates and long data format
I am trying to create a plot where I have a vline corrispondent to the crisis quarter (crisis variable is binary 1 (crisis)-0 (no-crisis). The piece of code
geom_vline(xintercept = as.yearqtr(c("2016-01-
01","2017-01-01")), linetype=4)+ #I should…

Jordan_b
- 305
- 1
- 8