wilkelab / ggtext

Improved text rendering support for ggplot2
https://wilkelab.org/ggtext/
GNU General Public License v2.0
650 stars 37 forks source link

not getting exponential from element_markdown() #100

Closed hunterdanielsmith closed 1 year ago

hunterdanielsmith commented 1 year ago

Cannot get exponential in axis title. image

ggplot(df, aes(x=sim, y=obs)) + geom_point(aes(shape=EXPERIMENT, color=EXPERIMENT), size=1.25) +
  scale_color_nejm() + geom_abline(linetype=2) + lims(x=lim, y=lim) +
  labs(x='Simulated Herbage Mass (kg ha^(-1))',y='Observed Herbage Mass (kg ha^(-1)') + 
  theme_bw() + theme(axis.title.x = element_markdown(), axis.title.y = element_markdown())

R version 4.2.2 (2022-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C LC_TIME=English_United States.utf8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] ggsci_2.9 ggtext_0.1.2 lubridate_1.9.1 yardstick_1.1.0 workflowsets_1.0.0 workflows_1.1.2 tune_1.0.1
[8] rsample_1.1.1 recipes_1.0.4 parsnip_1.0.3 modeldata_1.1.0 infer_1.0.4 dials_1.1.0 scales_1.2.1
[15] broom_1.0.3 tidymodels_1.0.0 forcats_1.0.0 stringr_1.5.0 dplyr_1.0.10 purrr_1.0.1 readr_2.1.3
[22] tidyr_1.3.0 tibble_3.1.8 ggplot2_3.4.0 tidyverse_1.3.2 DSSAT_0.0.6

loaded via a namespace (and not attached): [1] googledrive_2.0.0 colorspace_2.1-0 ellipsis_0.3.2 class_7.3-20 rprojroot_2.0.3 markdown_1.5
[7] fs_1.6.0 gridtext_0.1.5 rstudioapi_0.14 farver_2.1.1 listenv_0.9.0 furrr_0.3.1
[13] remotes_2.4.2 bit64_4.0.5 prodlim_2019.11.13 fansi_1.0.4 xml2_1.3.3 codetools_0.2-18
[19] splines_4.2.2 jsonlite_1.8.4 dbplyr_2.3.0 compiler_4.2.2 httr_1.4.4 backports_1.4.1
[25] assertthat_0.2.1 Matrix_1.5-1 gargle_1.3.0 cli_3.6.0 prettyunits_1.1.1 tools_4.2.2
[31] gtable_0.3.1 glue_1.6.2 Rcpp_1.0.10 cellranger_1.1.0 DiceDesign_1.9 vctrs_0.5.2
[37] iterators_1.0.14 timeDate_4022.108 xfun_0.37 gower_1.0.1 globals_0.16.2 ps_1.7.2
[43] rvest_1.0.3 timechange_0.2.0 lifecycle_1.0.3 googlesheets4_1.0.1 future_1.31.0 MASS_7.3-58.1
[49] ipred_0.9-13 vroom_1.6.1 hms_1.1.2 parallel_4.2.2 curl_5.0.0 rpart_4.1.19
[55] stringi_1.7.12 desc_1.4.2 foreach_1.5.2 lhs_1.1.6 hardhat_1.2.0 pkgbuild_1.4.0
[61] lava_1.7.1 commonmark_1.8.1 rlang_1.0.6 pkgconfig_2.0.3 lattice_0.20-45 labeling_0.4.2
[67] bit_4.0.5 processx_3.8.0 tidyselect_1.2.0 parallelly_1.34.0 magrittr_2.0.3 R6_2.5.1
[73] generics_0.1.3 DBI_1.1.3 pillar_1.8.1 haven_2.5.1 withr_2.5.0 survival_3.4-0
[79] nnet_7.3-18 future.apply_1.10.0 modelr_0.1.10 crayon_1.5.2 utf8_1.2.3 tzdb_0.3.0
[85] grid_4.2.2 readxl_1.4.2 callr_3.7.3 reprex_2.0.2 digest_0.6.31 munsell_0.5.0
[91] GPfit_1.0-8

bwiernik commented 1 year ago

You need to use the <sup></sup> and <sub></sub> tags for superscript and subscript