All Questions
74
questions
1
vote
1
answer
43
views
How to change legend key shape for ggtree [closed]
I am working with a ggtree plot. Data used is available here and you can pull the phylo tree directly from ggtree.
Load required packages
#load libraries
pacman::p_load(
here,
...
0
votes
0
answers
33
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
0
answers
28
views
ggplot legend in R not recognising aesthetic changes for label category with no data points
Consider the following image:
Although the underlying dataset does not contain values below 0.1 degrees Celsius, I want to and still can force the legend to display the label and box for 'Below 0.1', ...
0
votes
1
answer
61
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
84
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
528
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
199
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 ...
1
vote
1
answer
36
views
How can I match the colors of lines and legend entries in ggplot2?
I have a dataframe of some spectra (one x-value, several y-values) and want to plot them in one graph. For this purpose, I want to use ggplot. After some research, I found a way to do so, but I want ...
3
votes
2
answers
277
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
161
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
263
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
750
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
659
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 ...