Skip to main content

All Questions

Tagged with
14 votes
3 answers
8k views

Reverse order in R leaflet continuous legend

I am trying to reverse the value display of my leaflet legend in R. This post covers categorical data, but I am working with continuous data. Here's a toy example: map <- leaflet() %>% ...
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, ...
29 votes
2 answers
31k views

how to align the legend title to the middle of legend box in ggplot2?

I want to move the legend title sex a little right to the horizontal center of legend box. I tried theme and guide_legend but failed. Both ways won't change the legend title position. # example data ...
1 vote
2 answers
56 views

function for geom_point to increase the scale_size

LATER EDIT: I finally figured out how to do it. It works with the following code: legend_size <- c(6,5,4,3,2,1,0,1,2,3,4,5,6) tt <- data.frame(x = c(27.9656, 27.1704, 26.2128 ,23.5634 ,25.3528 ...
1 vote
2 answers
48 views

Add a legend to a voronoi diagram with field values

I try to create a map with a voronoi diagram of some climate stations. I've already created the diagram and also colored the areas in the diagram with a fitting color. Now I want a continuous legend ...
2 votes
1 answer
47 views

R ggplot2 need custom legend to have less values than corresponding line plot values to avoid duplicates

I have data which looks like the following: library(tidyverse) library(RColorBrewer) dat<-tibble( group = c(rep("Group 1", 10), rep("Group 2", 10), rep("Group 3", ...
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 = "...
1 vote
1 answer
35 views

Legend key color when combining ggOceanMaps and ggspatial

I am trying to combine basemap from ggOceanMaps with geom_spatial_point and having the geom_spatial_point having a new color scale. When I combine these two, the legend.key background color remains ...
0 votes
0 answers
24 views

How to color the legend labels in ggplot [duplicate]

Using the iris dataset, we can make a boxplot and customise the legend when plotting using ggplot like so: ggplot(data = iris, aes(x=Species, y=Sepal.Length, fill=Species))+ geom_boxplot()+ ...
1 vote
1 answer
38 views

ggplot of multiple geom_sf datasets gives mismatched legend colours

I am trying to create a ggplot map which includes two simple feature line datasets. I would like the lines to either appear in the same legend, or a separate legend. However the approach I am taking ...
1 vote
2 answers
51 views

adjusting the legend in TramineR plots

I am new to using TramineR and I just cannot seem to figure out how to arrange the legend in any of the plot types. The legend keeps being cut off by the plots. I have tried to use the seqlegend ...
0 votes
0 answers
28 views

Having problem adding legend onto my ggplot when ggplot's data argument is NULL [duplicate]

New to r here, so please bear with me. I am sure this is something simple to solve. I have this plot here and want to add a legend to distinguish which line represents the "Tailwater Gauge" ...
2 votes
1 answer
35 views

Rotating/angle of ggplot key_glpyh, custom legend key glyph

I am trying to emulate a plot style ive seen online, created by Chris Canipe (https://www.axios.com/2017/12/15/the-flow-of-goods-between-states-1513304375). Looking at trade flows, I've managed to ...
222 votes
11 answers
452k views

Plot a legend outside of the plotting area in base graphics?

As the title says: How can I plot a legend outside the plotting area when using base graphics? I thought about fiddling around with layout and produce an empty plot to only contain the legend, but I ...
1 vote
1 answer
27 views

R Customize ggVennDigram legend based on internally defined categories of mapped colors - not counts nor individual intersections

First time posting here... I have a Venn diagram where I have coded certain regions of intersections based on internally defined categories. I want to produce a legend that reflects those categories. ...

15 30 50 per page
1
2 3 4 5
166