Was asked to reduce the legend symbol thickness for a bar chart in ggplot2 (need them so thin that they look like narrow horizontal lines). Here is a simplification of my case:
library(ggplot2)
# Simple bar chart example
g <- ggplot(mpg, aes(class)) +
geom_bar(aes(fill = drv))
g
# Failed attempt to reduce the thickness of the legend symbol using guides().
# I also tried negative values, but that gives errors.
# However, increasing the size works well. I need the symbols very thin.
g2 <- g + guides(fill = guide_legend(override.aes = list(size = 0.1)))
g2
# Also adjusting with some theme options is not really working for me
# nor what I really need because is also reducing the distance between the labels.
g + theme(legend.key.height = unit(0.1, "mm"))
Perhaps there is no other way around than editing the legend grobs themselves with the functionality of the grid
package or do this outside of R, like Inkscape (?).
Created on 2019-05-21 by the reprex package (v0.2.1)