user10022403
user10022403

Reputation: 91

ggRadar - How to change plot line thickness and grid line thickess?

I've been using the ggRadar function from the ggiraphExtra package although have a couple of questions. Namely, how to change the line thickness and background gridline thickness.

I have tried changing the line thickness using geom_line but to no avail, as it doesn't interact with all lines. I have tried using theme(axis.etc) but can't interact with the gridlines (the background circles) in any way.

Here's a super simple example:

library(ggiraphExtra)
library(ggplot2)

data = as.data.frame(rbind(c(7,12,17,9))) 

ggRadar(data, rescale = F, size=3)+
  ylim(0,20)+
  geom_line(size=2)

Any help would be greatly appreciated.

Thanks!

Upvotes: 2

Views: 1605

Answers (2)

Arienrhod
Arienrhod

Reputation: 2581

You can easily modify the grid lines using panel.gridline.major in theme. Changing the thickness of the lines is somewhat harder but still possible.

p <- ggRadar(data, rescale = F, size = 4) +
  ylim(0,20) +
  theme(panel.grid.major = element_line(size = 2))
plot_obj <- ggplot_build(p)
plot_obj$data[[1]]$size <- 2
grid::grid.newpage()
grid::grid.draw(ggplot_gtable(plot_obj))

Original plot: original

Modified (ugly, but proves the point).

new plot

Upvotes: 3

user1147654
user1147654

Reputation:

I thing that you have to modify the panel.grid element like I do here to change the size:

 ggRadar(data, rescale = F, size=3)+
 ylim(0,20)+
 geom_line(size=1) + theme(panel.grid=element_line(size=2))

Upvotes: 3

Related Questions