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

Superscript '^' and subscript '_' don't work with gr() backend #2006

Closed
damonturney opened this issue Apr 22, 2019 · 4 comments
Closed

Superscript '^' and subscript '_' don't work with gr() backend #2006

damonturney opened this issue Apr 22, 2019 · 4 comments

Comments

@damonturney
Copy link

damonturney commented Apr 22, 2019

using Plots
gr()
plot(1,xlabel="hi^2")

doesn't produce a superscript.

And since latex doesn't work with gr() backend, see issue here #2005, there is NO way to produce superscripts or subscripts with the gr() backend.

@daschw
Copy link
Member

daschw commented Apr 23, 2019

doesn't produce a superscript.

It's not supposed to. You can use unicode symbols like ², or LaTeXStrings, which should work. I'm not sure why it does not for you.

Also, I recommend using ` or ``` around code in github issues. This makes it easier to read for others.

@daschw daschw closed this as completed Apr 23, 2019
@briochemc
Copy link
Collaborator

You can use unicode symbols like ², or LaTeXStrings, which should work.

Not all Unicode symbols work though. For example:

using Plots
scatter(rand(10), rand(10), xlabel="Digits superscripts (⁻¹²³⁴⁵⁶⁷⁸⁹⁰)")

produces (Julia v1.1.1, OSX v10.13.6, Plots v0.25.3, GR v0.41.0)
Screen Shot 2019-08-12 at 12 23 25 PM

Additionally, while LaTeXStrings provides a solution, IMHO it is not a good one because (i) it produces a different and serif font, and (ii), it doesn't allow to easily mix math and non-math mode AFAIU.

I think it is important for scientific plots to allow for a few superscripts and subscripts (mainly for units, thus the ⁻¹²³⁴⁵⁶⁷⁸⁹⁰ of my MWE above, and probably some straight-up greek letters like μ).

For that reason I tend to end up using the PyPlot backend more than the other options:

pyplot()
scatter(rand(10), rand(10), xlabel="Digits superscripts (⁻¹²³⁴⁵⁶⁷⁸⁹⁰)") 

which produces (PyCall v1.91.2, PyPlot v2.8.1)
Screen Shot 2019-08-12 at 12 27 39 PM

But anyway, this is probably more a GR.jl issue than a Plots.jl one though, right?

@JackDevine
Copy link
Member

Indeed this is a GR issue, I don't think that there is anything that can be done here on the Plots side.

@mzechmeister
Copy link

Sub- and superscripts works at least when using 10 as base and curly brackets

plot(1, xlabel="10^{-0123456789abc}_{-0123456789abc}")

grafik

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

5 participants