Changing legend title (and changing y axis variables to italic

Hi all,

Seem to be coming here more and more frequently!

I've been trying to change the legend title of my heatmap figure to "Frequency of Occurence (%)" (it currently is just "Frequency", as the variable is called).
I've got the following script:

SouthHeat <- ggplot(SouthMelt, aes(variable, Taxon)) +
  geom_tile(aes(fill = Frequency)) +
  scale_fill_gradient(high = "red", low = "white") +ylab("Taxa") +
  xlab("Transect") + theme(axis.text.x = element_text(angle = 90))
  
  
SouthHeat + labs(color = "Frequency of Occurence")

The script seems to run ok an doesn't flag any errors but nothing changes on my plot.

Thanks for any help!

PS I've been trying to change my y axis (my taxa) to be italicised but I can't find any code that changes that (usually just changes the y axis title). Would be great if anyone can help with that as well! Thanks! :smiley:

You are using the fill aesthetic in geom_tile(). Try

SouthHeat + labs(fill = "Frequency of Occurence")
1 Like

As for getting italic text, does adding this to your plot produce what you want?

 theme(axis.text.y = element_text(face = "italic"))

Brilliant, thank you so much for both those answers! Been scratching my head for a while for something so simple haha, thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.