duttashi / visualizer

My experiments in data visualizations. Feel free to show your :heart: by giving a star :star:
MIT License
15 stars 1 forks source link

How to add mathematical expression to a plot using ggplot2 or the base library #52

Open duttashi opened 6 years ago

duttashi commented 6 years ago

Often in plotting scientific diagrams there is a requirement for adding a subscript. The objective is to learn how to add subscripts in a plot using the ggplot2 library

duttashi commented 6 years ago

Add mathematical expressions to a plot

Reference

Want to write mathematical symbols and expressions in R graphics? You can use an R expression() instead of normal text, e.g. plot(1:10, main = expression(alpha + beta)). Below is a demo that shows you everything about plotting math in R (it was written by the R Core Team; see ?plotmath for details)

Combining expressions and text

If you want to combine multiple mathematical expressions with text, use paste() inside expression()