All Questions
104
questions
1
vote
1
answer
37
views
How to change legend key shape for ggtree [closed]
I am working with a ggtree plot. The data used is available here.
Load required packages
#load libraries
pacman::p_load(
here,
dplyr,
googlesheets4,
...
0
votes
0
answers
29
views
How to plot the legend with combined_plot (ggplot2)
I created this script to display some environmental impacts for my research.
`legend_plot <- ggplot(data_longGW, aes(x = Crop_cycleGW, y = kg_CO2_eq, fill = Category)) +
geom_bar(stat = "...
0
votes
1
answer
56
views
Force keys size to be smaller in multiple lines legend in ggplot
Is there any way to force legend key sizes to be independent from line height when we have legend text with multiple lines? I tried legend.key.height, ggtext::element_textbox_simple, and guides but ...
0
votes
1
answer
83
views
Separate out overlapping legend items ggplot()
The Issue
I have a plot that has various lines and symbols. They are all coloured by location ID. This has resulted in the legend items overlapping.
i.e.
There are four symbols: circle, triangle, ...
0
votes
1
answer
517
views
Using ggpattern with white pattern; fill and pattern different variables: How do I add a grey background to the pattern legend?
I am working on a graph and am using color and pattern for two different variables. I want the graph to have colored designs created by using a white pattern over the colored fills. (I tried making ...
1
vote
1
answer
196
views
get legend labels (text) from ggplot
I am trying to extract the label text from a ggplot legend object, e.g. for this plot:
library(ggplot2)
(p <- ggplot(mtcars, aes(x=mpg, y=disp, color=as.character(cyl))) + geom_point())
I can ...
3
votes
2
answers
273
views
Increase spacing between legend groups with patchwork settings
UPDATE:
The suggested code here
p1 + p2 + p3 + plot_layout(ncol = 1) +
plot_annotation(tag_levels = 'a') &
theme(legend.justification = "left")
returned this
I need to have the ...
1
vote
3
answers
160
views
Changing legend symbols in ggplot2
I have this plot made in ggplot2
With the following code:
colors4 <- c("Exp" = "#000000", "TL 1" = "#56B4E9", "TL 2"="#CC79A7", "TL ...
0
votes
1
answer
259
views
R survminer::ggsurvplot duplicates legend when setting linetype
Reproducible example:
require(Survival)
require(survminer)
require(ggplot2)
set.seed(42)
a <- c(32,291,545, 44,3,792,352, 20,615,169, 61,156, 88,863,255, 33,132,5,
63,8,964,831, 55,133, 12,...
0
votes
1
answer
60
views
Only one legends shows up: multiple legends in ggplot with different data types
I am trying to make a boxplot of 2 different beta coefficients (returned from a model) from two groups of categories and I want to overlay the "true parameterized" beta coefficient on top of ...
0
votes
1
answer
38
views
R ggplot mixed legend of two legends
Here is the graph that I have as a basis:
color_two_groups_type_2 <- c("dark red", "black")
pd <- position_dodge(0.4)
hedonic_price_indices %>% ggplot(aes(x=year, y=index,...
2
votes
1
answer
746
views
How to add a new (custom) variable to a ggplot legend
I've run a number of models with two estimated parameters per model with five groups and two treatments. I'm trying to graph the confidence intervals of these estimates in a large panel plot. Since, I'...
2
votes
1
answer
658
views
Add text to legend symbols in ggplot
Using geom_rect I am separating my data into classes in a ggplot.
These classes (v high, high, medium, low, v low) are denoted in the legend.
Is there a possibility to add the lower and upper limits ...
1
vote
1
answer
2k
views
How to make alpha (transparency) appear as continuous gradient in the ggplot legend?
Is it possible to make the transparency (alpha) appear as a continuous gradient in the ggplot legend? Currently, the plot looks like this:
Here, the different values for alpha are represented by dots ...
1
vote
0
answers
340
views
Leaflet legend with subtitles for grouped values
Is there a way to add subtitles to leaflet legends? The following example produces a functioning legend. However, is there a way to combine the subgroups to the same legend?
I could imagine this could ...