Questions tagged [gghighlight]

22 questions
4
votes
2 answers

gghighlight (R): Labeling bar charts

Alright, after a long silent read along, here's my first question. I am trying to add corresponding labels of unhighlighted items for a grouped barplot. When I insert gghighlight in front of the geom_text I get the following…
Arno
  • 43
  • 6
2
votes
1 answer

Is there a way to apply gghighlight on only some geoms in a ggplot?

I'm wondering if there's any way to have gghighlight only apply to geom_point() and geom_errorbar() but not geom_line(). If you look at the plot, gghighlight adds a new line to the graph connecting the two highlighted points, is there a way to stop…
Rhea
  • 31
  • 2
2
votes
1 answer

Apply gghighlight to multiple facets of time series plot

For the dataset df (the data is posted in the end of this question), I try to use gg_season() and gghighlight(year >= 2020) to highlight the lines after the years of 2020. But the output is obviously not as expected, how could I modify to year >=…
ah bon
  • 9,293
  • 12
  • 65
  • 148
2
votes
1 answer

Creating legends for several geom_hlines while using gghighlight

I want to create a legend for my horizontal lines in geom_hline. The data I am using comes from 3 different dataframes. I am also using gghighlight, I believe that it masks any legend. How do I force a legend in that case? The 3 dataframes are: 1)…
cyws
  • 35
  • 1
  • 6
2
votes
1 answer

R - gghighlight color for each line

I have a data frame with this format: df <- data.frame( id = c(1,1,1,2,2,2,3,3,3,4,4,4), time = c(1,2,3,1,2,3,1,2,3,1,2,3), value = c(1,3,5,2,4,6,3,5,7,1,4,7) ) I want to create individual plots highlighting each id and with other…
kquach
  • 161
  • 1
  • 10
2
votes
2 answers

gghighlight in clustered (grouped) bar chart in R

I need to use gghighlight in a clustered bar chart in R in order to highlight only one single bar. My code and sample data looks like this: library(tidyr) library(ggplot2) dat <- data.frame(country=c('USA','Brazil','Ghana','England','Australia'),…
Ben
  • 23
  • 5
2
votes
1 answer

How to highlight a line connecting a group in ggplot R?

I'm very new to R and I'm looking to highlight certain groups in my plot using gghighlight. For example, I want to highlight in red only groups 16 and 32 while leaving the rest of the lines in gray. My current code and output are below. I can't seem…
ej-25
  • 21
  • 1
  • 5
1
vote
1 answer

Using gghighlight with ggmap

I can make a map using ggmap using code below, but if I try to use gghighlight I get an error. Is it possible to use gghighlight with ggmap? library(ggmap) hdf <- get_map("houston, texas") mu <- c(-95.3632715, 29.7632836); nDataSets <-…
luciano
  • 13,158
  • 36
  • 90
  • 130
1
vote
1 answer

Error when using gghighlight to highlight one group of data

I have data on in-hospital cardiac arrest that contains month, event location (Unit), number of events in that location for that month (unitCount), and percentages of if the event was witnessed, if epinephrine was given, if defibrillation occurred,…
C Chen
  • 25
  • 4
1
vote
1 answer

Add legend labels to the right of each line in a ggplot2 line chart

I'm building a line chart and I'd like the (markdown-formatted) legend labels to be displayed right next to the last data point for each line; something like this: What I've tried: First attempt: using geom_text but there are some issues: the…
Andrea M
  • 2,314
  • 1
  • 9
  • 27
1
vote
1 answer

How to use gghighlight when also using ggplot, geom_line and group

I can't figure out to plot my data using geom_line and geom_point so that gghighlight works without needing the variables to be in the global environment library(ggplot2) library(gghighlight) Create some data x <- rep(1:5, 4) y <- c(rep(1:5, 1) +…
1
vote
2 answers

Code for adding an average line in ggplot?

I have used the code below to make the ggplot added as an image further down. The plot is a duration curve showing water discharge on the y-axis, and percentage of time on the x-axis. The lines represents one singular year of water discharge…
Saron B
  • 39
  • 6
1
vote
2 answers

Highlight Only Flagged Values

I am trying to highlight only certain points on a combo line + point plot in ggplot2. Here's a bit more background. In this data set, whenever a value goes outside a certain range, it is flagged as out of spec. In the column "in_spec", if a value…
setty
  • 425
  • 3
  • 18
1
vote
1 answer

I'm trying to use gghighlight with directlabels

I have the following code, it plots without issue, except I only get the first label showing and it is in the bottom right corner rather than at the end of the line. Where have I gone wrong? p1 <- ggplot() + geom_line(data = data.cn, aes(dateRep,…
Spatial Digger
  • 1,883
  • 1
  • 19
  • 37
0
votes
0 answers

How can customize the line width for groups in facetted graph in ggplot?

Although my question is related to line graph, it can be generalizable for other types of graphs and here it is. Recently, I am trying to plot a facetted geom_line to show the annual change in particular groups given in my dataset. In other words, I…
mzkrc
  • 219
  • 2
  • 7
1
2