Marissa Fahlberg
Marissa Fahlberg

Reputation: 21

How can I make the legend horizontal in the euler plot in R?

I'm having difficulty styling this euler plot. One of my main issues is that I'd like the legend to be on the bottom, but display the variables horizontally. They look strange stacked vertically.

If anyone also knows how to adjust the margins, add a border around the whole plot, and add a subtitle, I'm stumped on those things too. I've already tried par(mar) and that didn't have any effect.

fit1 <- euler(c("Day 1" = 69, "Day 2" = 109, "Day 3" = 152,
                "Day 1&Day 2" = 11, "Day 1&Day 3" = 18, "Day 2&Day 3" = 28,
                "Day 1&Day 2&Day 3" = 2))

col <- c("#66D2D6", "#FBC740", "#E56997")

plot(fit1,
     quantities = TRUE,
     fills = list(fill = col, alpha = 0.8),
     edges = "black",
     main = list(label = "test", cex = 0.9),
     legend = list(side = "bottom"))

enter image description here

Upvotes: 1

Views: 1322

Answers (1)

user2554330
user2554330

Reputation: 44917

The plot method for euler objects uses grid::grid.legend() to plot the legend. You can specify any of grid.legend's arguments in the legend argument to plot (which really calls plot.euler). To get a horizontal legend, use

plot(fit1,
     quantities = TRUE,
     fills = list(fill = col, alpha = 0.8),
     edges = "black",
     main = list(label = "test", cex = 0.9),
     legend = list(side = "bottom", nrow = 1, ncol = 3))

Upvotes: 3

Related Questions