ggplot Legend update

 



## Legend title
legendTitle <- "new title" # or NULL if you do not want to show the title

P +  guides(
title = NULL,
fill=guide_legend (
title = NULL,
keywidth=0.2, # specifying the width of the legend key.
keyheight=0.2, # specifying the height of the legend key.
default.unit="inch")
)

# Legend key label changes

newLabels <- c("Competitors", "Mirixa") # should be in order of color values below.
p + scale_fill_manual(values=c("Khaki", "Tomato"), labels = newLabels)

# Legend position
P + theme (legend.position = "bottom", # or "top", "left", or "right"
legen.dkey = element_rect(color = "white), # legend key background color in case of calling theme_bw()
)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s