Skip to main content

All Questions

Tagged with
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, ...
Blundering Ecologist's user avatar
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 ...
Alexander Klug's user avatar
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 ...
Alex.V's user avatar
  • 55
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", ...
costebk08's user avatar
  • 1,347
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 = "...
Guido Evangelista's user avatar
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 ...
Camille Pagniello's user avatar
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()+ ...
Ginko-Mitten's user avatar
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 ...
David's user avatar
  • 205
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 ...
user25809482's user avatar
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" ...
Matt Schaaf's user avatar
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 ...
Rupert Stacy's user avatar
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. ...
dGroat's user avatar
  • 11
0 votes
1 answer
38 views

Trying to remove the background of color icon in ggplot legend

I'm trying to remove the gray box behind the color icon in the legend of this graph. Wondering if the issue is that I'm using geom_col() so the color aesthetic is just the outline of the column. Does ...
lp_bae_ncsu's user avatar
0 votes
1 answer
49 views

Reorder legend levels in CalendR

Using CalendR to plot fishing days for boats. How do you go about reordering legend levels e.g. boat names first then public holidays last? Load packages, create events & plot calander: ## load ...
Tuna-92's user avatar
  • 27
0 votes
0 answers
20 views

Increase spacing in ggplot legend items [duplicate]

I have two shapefiles of a Country, one containing the geometry of the municipalities and the other regarding the border of the regions of the country. I have to plot the country with the ...
Coppertank's user avatar
0 votes
1 answer
43 views

Edit legend title in ggplot2 (3.5.1) [duplicate]

I have successfully edited the x and y axis titles, but I'm stuck on the legend title and labels. Here is the code I have run so far: m.emo.plot <- interact_plot(model = m.emo, pred = cemodiff, ...
medusa's user avatar
  • 45
0 votes
1 answer
27 views

How to avoid overlapping legends for multiple geom_point layers in ggplot2

I'm trying to create a chart with 2 geom_points and a geom_text_repel layer. When I display my legend, the geom_points overlap. The main data points should be represented as empty circles, while the &...
NoNameBoyy's user avatar
1 vote
1 answer
29 views

How to Add a Legend to a ggplot with two axes

I've put together this graph and I would like to be able to add a legend to it but can't seem to figure out why it's not showing up and how to easily add it. data <- data.frame(group = LETTERS[1:5],...
Patrick Jung's user avatar
0 votes
1 answer
19 views

Centering a `ggplot2` Plot Legend in a Blank Plot

I have the following graph. ggplot() + geom_hline(aes(yintercept = 0, linetype = "Line 1"), color = "white", size = 1.25) + geom_hline(aes(yintercept = 0, linetype = "Line ...
David Moore's user avatar
0 votes
1 answer
35 views

Changing the Legend Title in a `ggpointdensity` Density Scatterplot [duplicate]

I have the following data and the following graph. df <- data.frame(col1 = rnorm(1000, 0, 0.05), col2 = rnorm(1000, 0, 0.05)) ggplot(data = df, mapping = aes(x = col1, y = col2)) + ...
David Moore's user avatar
0 votes
1 answer
65 views

Add legend after using gg.gap

I have a data set with a big negative value, so I used gg.gap package to make a discontinuous y-axis. The code worked well but after adding the function gg.gap the legend was deleted. I tried adding a ...
Gonzalo de Quesada's user avatar
2 votes
1 answer
44 views

How can I make the legend appear on this chart?

I've drawn this quartile for the runoff rate, and I'd like the legend to appear as: - Median and - Q25-Q75. Can you please help me? Runoff <- data.frame(Year = rep(1991:2002, each = 12), ...
Barre's user avatar
  • 31
0 votes
1 answer
38 views

I want to get two legends for two different groups in a two Y-Axis plot [closed]

so I have a two Y-Axis plot. Each Y-Axis is given a group of Data. I want to have two different legends for each group on left and right side of plot on the locations shown in the second picture. This ...
Nick Brown's user avatar
0 votes
0 answers
20 views

Change Orientation and Order of Items in Legend ggplot2 r [duplicate]

Is there a way to change the orientation of the items in the legend of ggplot2 chart? I have a series of boxplots where I would like the individual items to oriented vertically opposed to horizontally....
Englishman Bob's user avatar
0 votes
1 answer
29 views

Variable legend outlined in appropriate color, but filled with black dot

I have used ggplot in R to generate a dot plot with three "samples" (Adipocytes, BAT and WAT) which are colored by ""group". The plot is correct, but the "group" ...
Numbahs84's user avatar
0 votes
3 answers
39 views

Legend is not shown using ggplot2 despite using color within aes()

I have a problem making the plot legend to show. I've checked other posts and most of them mention that color should be defined within the aes() of the ggplot. So I have the following dataset: date ...
Tassos Pan's user avatar
1 vote
0 answers
30 views

Why is the coding for legend on my barplot not working after update?

I updated Rstudio and suddenly none of my legends are working on my barplots. It's my first time asking for help on here, so hopefully I am providing the info needed to get answers? Coding is below. ...
Rebecca Connor's user avatar
0 votes
1 answer
63 views

How to center legend text in ggplot

I have a plot that looks like this: I used these data and code to produce it: structure(list(zone = c("Zone 1", "Zone 2", "Zone 3", "Zone 4", "Zone 5&...
Ryan Gary's user avatar
  • 141
2 votes
2 answers
168 views

Specify which legend to keep in wrap_plots

I'm looking to combine multiple graphs generated from different functions into a single display. Specifically, I want to only keep the legend of the first graph in the wrap. Here is a minimal version ...
NoNameBoyy's user avatar
0 votes
1 answer
45 views

Legend is not reflecting symbol plotted in ggplot2

I have a dataframe that looks like this: structure(list(season = c("Fall", "Spring", "Summer", "Winter" ), effort = c(2559.85453311966, 4741.60449074074, 2014....
Ryan Gary's user avatar
  • 141
0 votes
1 answer
40 views

How to reverse legend order without affecting bar order in Plotly R? [duplicate]

I am creating a stacked bar chart using Plotly in R, and the order of the items in the legend is the reverse of the order that I want. library(dplyr) library(plotly) library(forcats) set.seed(1) df &...
Ernest Au's user avatar
0 votes
0 answers
13 views

Visnetwork not displaying visLegend properly

I am using the package VisNetwork and one of the attributes of the nodes contains 9 different possibilities, as follows. This is just a minimal example. In my real dataset, the column "family&...
wigo's user avatar
  • 3
1 vote
1 answer
143 views

Order of ggplot ignoring order of legends

With the following data, I am trying to create a plot as shown, but the order of legends as: mgCST Group, CST Group, Treatment Status. However, ggplot is ignoring all attempts to order the legends ...
AWillz's user avatar
  • 23
-1 votes
1 answer
40 views

Add horizontal lines with according color and legend to ggplot using R

I want to add horizontal lines so that the lines have y-intercept of period and colors according to their obj_name, ie the same colors as the line plot for each object. I succeeded in putting in these ...
Jason Liu's user avatar
0 votes
1 answer
45 views

how to have a legend for size of geom_points() and also set the size of the dots themselves?

I am trying to plot a sort of bubble plot but i am unable to set the size of the dots and have a legend explaining how the sizing works. These are two examples which combined give me the expected ...
gabt's user avatar
  • 774
0 votes
1 answer
19 views

ggplot manually adjusting attributes

I am trying to change the legend on this plot in ggplot. I want it to have both the appropriate linetype and color in the one legend. However, I would be satisfied if I could just fix the linetype ...
kpr62's user avatar
  • 561
1 vote
1 answer
116 views

how to change size of symbol in ggplot2 when size, shape, and color are set through geom_point?

The problem i am having is surely trivial, and yet i am unable to solve it. What i need is to have my own shape, colour, and size for the geom_point(). However, if i set it, the size of the symbols in ...
gabt's user avatar
  • 774
2 votes
0 answers
47 views

Add p-value breaks to a gene oncology dot plot [closed]

I am so close to finishing up a gene oncology-gene ratio figure for a lab assignment, but I am struggling with adjusting my p-value breaks. I'd like to have control to having p-value range from 0.001 ...
KenH's user avatar
  • 31
0 votes
0 answers
41 views

R's plotly ggplotly removing legend from a geom_point

I'm generating a simple geom_point plot with R ggplot2: library(dplyr) library(ggplot2) set.seed(1) df <- matrix(runif(16, 0, 10), nrow = 4, ncol = 4, dimnames = list(paste0("R", 1:4), ...
dan's user avatar
  • 6,242
1 vote
2 answers
42 views

Separate Legend Entries for Individual Outlined Overlapping Bars

I am creating a ggplot with multiple overlapping bar plots. The first underlying bar is filled with color and then I overlay one more set of bars with just an outline to show sub-components. I would ...
fowlermw's user avatar
0 votes
1 answer
78 views

How to show values next to bars in tornado chart using ggplot in R [closed]

I have this table (T_Tornado_Total_EM_HM_sort): And these are the lines that I used to make the tornado chart: ggplot(T_Tornado_Total_EM_HM_sort, aes(Tipovi_troškova, RSD, fill=Populacija)) + ...
newtoR's user avatar
  • 35
0 votes
0 answers
46 views

Is there a way to move the legend in a trackViewer lollipopPlot and/or change its orientation?

Is there any way to alter the position or orientation of a legend in a trackViewer lollipopPlot (or fudge something that performs the same function), so that it's on the side of the plot and directly ...
KeyboardCat's user avatar
0 votes
1 answer
35 views

ggplot2 - how to keep the legend items with the same size, when geom_segment() has different sizes? [duplicate]

I'm plotting several segments as once using ggplot2, with two different sizes. An example of what I want to do is provided in one of the answers here. Here's the example they provide: ggplot2::ggplot()...
mto23's user avatar
  • 391
0 votes
3 answers
63 views

Having different shapes of points for each line and making them shown on the legends

My goal is to make the graph look something like this My Goal. The problem I'm having is that ggplot won't let me use more than 6 kinds of shapes for the points, so my graph looks something like this ...
Jason Liu's user avatar
0 votes
2 answers
37 views

Overlapping legend of a line plot

I want to show each line as having a different color and shape, and that should be reflected on the legend. Basically, it should look something like this My Goal. I could make the color and point ...
Jason Liu's user avatar
1 vote
0 answers
35 views

How to align legend elements in the middle when they are on two rows using ggplot2?

In the MWE below, the caption appears separated into two rows. I want the item corresponding to gear 5 to be aligned in the middle in relation to gears 3 and 4 above it. How can I do this? library(...
Daniel Valencia C.'s user avatar
0 votes
1 answer
94 views

How do I add a legend to ggplot with two scatter plots (geom_point() )

I have a table I read into R to plot with ggplots. I need to plot two sets of data points and also use an ifelse condition to be able to show specific genes. I would like to show a legend to the plot, ...
Assa Yeroslaviz's user avatar
1 vote
1 answer
105 views

How to customize the legend order for a 3D scatter plot?

I'm trying to generate a 3D scatter plot and the shapes of markers correspond to 'Treatment' (IC, IT, YS), whilst, the colors correspond to 'Time' (0, 2, 4, 6, 12, 24, 48, 72). Everything went well ...
SIV0625TriX's user avatar
1 vote
1 answer
75 views

Title and legend adjustment with `grid.arrange`

I have 6 different plots in R that I want to arrange in one plot with grid.arrange. They share the same legend, but whenever I want to put a common legend, the sizes of the plots are adjusted ...
Masal Gezici's user avatar
0 votes
0 answers
26 views

Entrywidth argument not working in R plotly

I am trying to make an interactive plot with the plotly package. The legend needs to be next to the image and have a certain width. I now have the issue that the default appears to be that the legend ...
Bramminator's user avatar

15 30 50 per page
1
2 3 4 5
50