0

I cannot scale a legend when using the draw_plot function.

df = data.frame(x=c(1,2,3), y=c(1,2,3), pval=c(0.01, 0.1, 1))
gg = ggplot(df, aes(x=x, y=y, color=pval))+geom_point()

leg = get_legend(gg)

gg + theme(legend.position = "none") + 
   draw_plot(leg, x=2.9, y=2.2, width=0.1, height=0.2, scale=0.1)

I played around with the width, height and scale arguments and came to the following conclusion: width and height shifts the legend (add values to to x,y coordinates), whereas scale does nothing.

What am I missing?

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
user7727736
  • 97
  • 1
  • 8
  • I guess one just has to set the barheight and barwidth according to your needs in guilde_colorbar. – user7727736 Nov 27 '18 at 16:55
  • grid graphics has absolute distance measures and relative distance measures. The scale option only affects relative distance measures. However, in the legend, all relevant sizes are absolute distance measures. So yes, a legend can't be scaled like that. – Claus Wilke Nov 27 '18 at 23:55

0 Answers0