Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird spacing when using <sup></sup> combined with Greek letter #68

Open
FrancescoGarassino opened this issue Aug 5, 2021 · 2 comments

Comments

@FrancescoGarassino
Copy link

FrancescoGarassino commented Aug 5, 2021

Hi, and thank you for providing us with such a convenient package! I unfortunately ran into an issue I'd need some support for. I happen to use quite a lot units of measurements in my plots which are in the form of micrograms per squared meter, so I need to combine Greek letter mu and superscript (see an example below). However, when doing so I get a very weird spacing between my 'm' and the superscript 2.

library(ggplot2)
library(ggtext)

ggplot(data = iris, aes(x = (Petal.Length)^2, y = Petal.Width)) +
  geom_point() +
  xlab("Petal Length (&mu;g/m<sup>2</sup>)") +
  theme(axis.title.x = element_markdown())

Test1

I tried removing the Greek mu and everything seems to be working fine:

library(ggplot2)
library(ggtext)

ggplot(data = iris, aes(x = (Petal.Length)^2, y = Petal.Width)) +
  geom_point() +
  xlab("Petal Length<sup>2</sup>")+
  theme(axis.title.x = element_markdown())

Test2

Do you have a solution for this issue?

Thanks a lot in advance!

@Matthionine
Copy link

Hello @FrancescoGarassino
Do you still experience this issue?
I was curious and tried your example and here it works fine.

r 4.1.3
ggtext 0.1.1

@chuyaowang
Copy link

I had the same issue. The superscript worked fine before, but had a space before it when I ran the script after doing some other plotting. It seems to be related to how R uses the graphics device, as restarting R Studio resolved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants