library(ggplot2) p <- ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) + geom_boxplot() p Change the legend position The position of the legend can be changed using the function theme() as follow : p + theme(legend.position="top") p + theme(legend.po...
<pre> theme( ##no legend.title legend.title = element_blank(), ## legend border legend.box.background = element_rect( size = 1), ##legend inside, change relative positions by 0.95, 0.95 legend.position = c(.95, .95), legend.justification = c("right", "top"), legend.box.just =...
Control legend position withlegend.position You can place the legend literally anywhere. To put it around the chart, use thelegend.positionoption and specifytop,right,bottom, orleft. To put it inside the plot area, specify a vector of length 2, both values going between 0 and 1 and giving...
* this is not part of ggplot specs * Legend Options for each legend */ fun padding(): Double // Space around legend content (px) fun margins(): Thickness // Space between legends fun spacing(): DoubleVector fun position(): LegendPosition 25 changes: 20 additions & 5 deletions 25 .....
x sets the x position with respect to xref from "0" (left) to "1" (right), and y sets the y position with respect to yref from "0" (bottom) to "1" (top). Moreover, you can define xanchor to left,right, or center for setting the title's horizontal alignment with respect ...