kaito
September 11, 2022, 5:30am
1
Need help making the superscripts for grams of carbon per meter squared per year (g C m yr).
pp_plot <- gplot(ras.stack[[5]])+
geom_raster(aes(x=x,y=y,fill=value)) +
scale_fill_viridis_c(na.value="grey95", name = "Primary production (g C m yr)") +
theme_bw()+
labs(tag = "D") +
theme(legend.position = "bottom",
legend.key.size = unit(0.5, 'cm'),
legend.key.height = unit(0.5, 'cm'),
legend.key.width = unit(0.5, 'cm'))
DavoWW
September 11, 2022, 7:10am
2
Hi @kaito ,
Welcome to the RStudio Community Forum.
Try this:
x_name <- c(expression(paste( "Primary production (g C m"^{"-2"},".yr"^{"−1"},")")))
plot(1,1, xlab=x_name)
Created on 2022-09-11 with reprex v2.0.2
Getting this to work correctly can be quite tricky. See help(plotmath)
.
I discovered that I needed to quote the "-2" and "-1" to get this example to work as required.
kaito
September 11, 2022, 8:26am
3
Great that worked. Thank you so much!
system
Closed
October 2, 2022, 8:27am
4
This topic was automatically closed 21 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.