When using theme_bw, how can I remove the grey borders around individual entries in a ggplot2 legend?


Gimelist

I have the following code in R:

library(ggplot2)
theme_set(theme_bw())
p <- ggplot(mtcars, aes(wt, mpg))
p <- p + geom_point(aes(colour = factor(cyl)))
p

turn out:

ggplot2 grey border in legend

Each legend entry has a gray border around it. How to delete?

Tonitonov

just add

+ theme(legend.key = element_rect(colour = NA))

enter image description here

Related


How can I remove the light grey border around the Canvas widget?

Rectangle Rectangle: I've been messing around with Tkinter Canvaswidgets to see if I can make some nice looking widgets, and I have a few questions. First of all, why is there a light grey border around my Canvas widget and how do I get rid of it? Second, why

How can I remove the light grey border around the Canvas widget?

Rectangle Rectangle: I've been messing around with Tkinter Canvaswidgets to see if I can make some nice looking widgets, and I have a few questions. First of all, why is there a light grey border around my Canvas widget and how do I get rid of it? Second, why

Remove grey from legend in ggplot2

Xu Wang I want to remove the grey color from the legend box (this is because of SE in geom_smooth). I want to keep SE in the actual plot. So, in the legend box, I only want the color of the line, not the shadow. Here is an example: library(ggplot2) x <- rnorm

Remove grey from legend in ggplot2

Xu Wang I want to remove the grey color from the legend box (this is because of SE in geom_smooth). I want to keep SE in the actual plot. So, in the legend box, I only want the color of the line, not the shadow. Here is an example: library(ggplot2) x <- rnorm

Remove grey from legend in ggplot2

Xu Wang I want to remove the grey color from the legend box (this is because of SE in geom_smooth). I want to keep SE in the actual plot. So, in the legend box, I only want the color of the line, not the shadow. Here is an example: library(ggplot2) x <- rnorm

Center plot title in ggplot2 using theme_bw

Hennessy By default, titles are left-aligned starting with ggplot 2.2.0. How to center them again has been explained in this post: Center plot title in ggplot2 This also works fine in my case, but not if I use theme_bw. dat <- data.frame( time = factor(c("Lu

Center plot title in ggplot2 using theme_bw

Hennessy By default, titles are left-aligned starting with ggplot 2.2.0. How to center them again has been explained in this post: Center plot title in ggplot2 This also works fine in my case, but not if I use theme_bw. dat <- data.frame( time = factor(c("Lu

Center plot title in ggplot2 using theme_bw

Hennessy By default, titles are left-aligned starting with ggplot 2.2.0. How to center them again has been explained in this post: Center plot title in ggplot2 This also works fine in my case, but not if I use theme_bw. dat <- data.frame( time = factor(c("Lu

Center plot title in ggplot2 using theme_bw

Hennessy By default, titles are left-aligned starting with ggplot 2.2.0. How to center them again has been explained in this post: Center plot title in ggplot2 This also works fine in my case, but not if I use theme_bw. dat <- data.frame( time = factor(c("Lu

How to use darker gridlines for theme_bw() in ggplot2?

grouse How to get darker gridlines theme_bw()in ggplot2 ? I've seen some answers, but most of them are too complicated to use theme(). Is there an easier way? corr.plot.contour(data=foo1,x='log(area)',y='log(fd)',xl='Basa(log)',yl='Flo'+stat_smooth(method="lm"

How to use darker gridlines for theme_bw() in ggplot2?

grouse How to get darker gridlines theme_bw()in ggplot2 ? I've seen some answers, but most of them are too complicated to use theme(). Is there an easier way? corr.plot.contour(data=foo1,x='log(area)',y='log(fd)',xl='Basa(log)',yl='Flo'+stat_smooth(method="lm"

How to use darker gridlines for theme_bw() in ggplot2?

grouse How to get darker gridlines theme_bw()in ggplot2 ? I've seen some answers, but most of them are too complicated to use theme(). Is there an easier way? corr.plot.contour(data=foo1,x='log(area)',y='log(fd)',xl='Basa(log)',yl='Flo'+stat_smooth(method="lm"

How to use darker gridlines for theme_bw() in ggplot2?

grouse How to get darker gridlines theme_bw()in ggplot2 ? I've seen some answers, but most of them are too complicated to use theme(). Is there an easier way? corr.plot.contour(data=foo1,x='log(area)',y='log(fd)',xl='Basa(log)',yl='Flo'+stat_smooth(method="lm"

Cannot remove grey area behind legend symbol when using smooth

bridge I am using ggplot2 with GAM smoothing to see the relationship between two variables. When plotting, I want to remove the grey area after the symbols for both types of variables. For this I would use theme(legend.key = element_blank()), but it doesn't se

Cannot remove grey area behind legend symbol when using smooth

bridge I am using ggplot2 with GAM smoothing to see the relationship between two variables. When plotting, I want to remove the grey area after the symbols for both types of variables. For this I would use theme(legend.key = element_blank()), but it doesn't se

Remove borders around points in ggplot

Italian Marmite I have a scatterplot with two sets of distinct points based on different datasets. I wanted one of the points to have a border, so I used , pch = 21, which changed the points to a circle with a border and inside. I want the other set of points

Draw borders around certain lines using Cowplot and ggplot2

username I would like to somehow indicate that certain rows in a multi-panel plot should be compared. For example, I want to draw this graph: A plot that looks like this (with boxes around the panels made in PowerPoint): Here is the code I wrote using the firs

Draw borders around certain lines using Cowplot and ggplot2

username I would like to somehow indicate that certain rows in a multi-panel plot should be compared. For example, I want to draw this graph: A plot that looks like this (with boxes around the panels made in PowerPoint): Here is the code I wrote using the firs