Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
2 votes
1 answer
5k views

position legend "bottom" in theme_bw() or theme_classic()

I want to plot something without using theme(), but instead theme_classic(). How can I change the position of the legend to the "bottom"? Thanks!
Beatrice Mihaela's user avatar
1 vote
1 answer
67 views

How to globally define the aesthetics of a color bar guide in ggplot2?

I have a plot that has a legend with a color bar. By default tick marks are white. I can change them to black in each plot using guides(fill = guide_colorbar(ticks.colour = "black"). Is ...
Daniel Valencia C.'s user avatar
1 vote
1 answer
690 views

Include guide() in ggplot2 theme

Our organization has a very exacting style book, so I've been tasked with creating a ggplot theme that programmers can use to ensure that their charts and graphs are as close as possible to "...
leviemb's user avatar
  • 59
0 votes
2 answers
189 views

ggplot2: move (reposition) the legend so as not to block the graph box

How can I shift the legend by several points (the width of the graph box line) to the left and bottom? Task: I want to make the background of the legend semi-transparent, but so it doesn't overlap ...
Zhihar's user avatar
  • 1,378
1 vote
0 answers
548 views

Using and adapting bbc style theme in ggplot R

I am trying to use the bbc style theme to make my plots in gg plots nicer. However, I am finding that bbc style theme automatically removes axis labels and legend labels, even if I include axis labels ...
sim's user avatar
  • 13
2 votes
0 answers
235 views

Multiple Legends With Different Themes R

So I made a plot with multiple legends in it, but due to circumstances, I would like to make them in a different location and have the line's legend not have such a thick border. Here's the code: ...
L.Zingg's user avatar
  • 85
0 votes
1 answer
133 views

Legend position set in theme is saving as "right" even when set to another value

I'm creating a bunch of graphs that I want to share a theme, for consistency because who doesnt love consistency. All of my theme() elements are holding except for legend.position, and I'm all out of ...
Morgan Browning's user avatar
1 vote
1 answer
118 views

distance to legend text ggplot

I am trying to get a little more distance between the legend box (indicator) and the legend text. I have a code adapted from this amazing page. Here is my MWE: library(openxlsx) # for ...
LHM's user avatar
  • 31
0 votes
1 answer
252 views

R/ggplot2: figure legend for size has weird blobs covering sample data points

Surprised not to be able to find this here, I'm guessing this is a common problem. I'm drawing boxplots in ggplot, plus plotting the data points themselves with geom_point() or geom_jitter(). When ...
Nathan Siemers's user avatar
1 vote
2 answers
603 views

Add item to legend by theme options

I have a data frame d like this: d <- data.frame("name" = c("pippo","pluto","paperino"), "id" = c(1,2,3),"count" = c(10,20,30), "pvalue"=c(0.01,0.02,0.05), geneRatio=c(0.5,0.8,0.2), type=c("KEGG",...
TheAvenger's user avatar
0 votes
0 answers
93 views

Which command in my code is preventing a custom theme and legend labels from working?

So i am trying to make graph mapping coral cover degradation. From the attached graph you can see i am almost there, i am just trying to add custom labels to my legend and a custom theme to change up ...
Matt G's user avatar
  • 21
-2 votes
1 answer
5k views

Full manual legend with shape, linetype, labels defined in ggplot2

I have have constructed a plot with monthly temperature data with following command. Here I need to add a legend with defined shape(16, 17, 18...), linetype(1,1,2,....), and labels (1977, 1978, 1979......
MKS's user avatar
  • 13
2 votes
1 answer
2k views

ggplot2 - alignement of legend items

I try to plot the following data: amazon_ghm <- structure( list(MONTH = 1:12, MEDIAN = c(-736.12, 3340.83, 7144.85, 9927.73, 10986.7, 1526.48, -4415.36, -3213.32, -3435.17, -5112.405, -...
steve's user avatar
  • 521
2 votes
2 answers
1k views

Automatically resizing legend for a plot made using ggplot2 such that the entire legend lies within the boundary of the layer

I have some data here I read the data into a data frame and then plot this data with this following code, # Reading data from a .csv file into a data frame df <- read.table("newcsv_file.csv",...
Amm's user avatar
  • 1,789