Sun Symbol with LaTeXStrings

Hello!

In the past, I’ve used LaTeXStrings to label plot axis with solar units, like the solar luminosity on the y-axis of the plot below, with “\astrosun”. It seems that neither “\astrosun” nor “\odot” are recognized now? I get “undefined symbol” for both.

Is there a good way to make the sun symbol? I would rather not use “_{sun}” because it seems unprofessional.

Thanks!

What plotting package/julia version are you using?
With Plots.jl using the PyPlot backend on Julia 1.0 I can’t use \astrosun inside a LaTeXString but I can use \odot or the tab-completed unicode characters for \astrosun or \odot:

using Plots, LaTeXStrings
pyplot()
plot(rand(10), rand(10), ylabel = L"log_{10} L_{\odot} L_☉ L_⊙")

fig

Might be a topic for Visualization

Thanks @benelsen!

I’m using Plots with the GR backend on Julia 1.0. Does the LaTeXStrings package only work with certain backends?

Yes, GR doesn’t currently play nicely with LaTeX, so you have to use another backend. Related issue here: Consistent LaTeX support using the gr() backend to Plots

PGFPlotsX example (just grabbed numbers from Wikipedia, may not make sense):

using PGFPlotsX

luminosity = [500000, 20000, 800, 80, 20, 6, 2.5, 1.26, 1, 0.79,
              0.40, 0.16, 0.063, 0.0079, 0.0008]
temperature = [38000, 30000, 16400, 10800, 8620, 7240, 6540,
               5920, 5780, 5610, 5240, 4410, 3920, 3120, 2660]
push!(PGFPlotsX.CUSTOM_PREAMBLE, raw"\usepackage{wasysym}") # for \astrosun

@pgf Axis({ xlabel = raw"Temperature [$\times 10^3 K$]",
            ylabel = raw"$\log_{10}$ Luminosity [$L_{\astrosun}$]"},
          Plot(Table(temperature / 1000, log10.(luminosity))))

plot

Thanks @nilshg! I hope that this issue will be fixed soon.

Thanks @Tamas_Papp! I haven’t used PGFPlotsX before, but will try it. I’ve previously used GR because it’s fast