# Sun Symbol with LaTeXStrings

**URL:** <https://discourse.julialang.org/t/sun-symbol-with-latexstrings/15250>\
**Category:** Visualization\
**Created:** [September 20, 2018, 7:28pm UTC](https://discourse.julialang.org/t/sun-symbol-with-latexstrings/15250 "2018-09-20T19:28:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![astrowanders](https://avatars.discourse-cdn.com/v4/letter/a/e47774/32.png) [@astrowanders](https://discourse.julialang.org/u/astrowanders)\
**Post date:** [September 20, 2018, 7:28pm UTC](https://discourse.julialang.org/t/sun-symbol-with-latexstrings/15250/1 "2018-09-20T19:28:47Z")

</div>

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!

 ![1Msun_evolution_MESA_ed](https://global.discourse-cdn.com/julialang/original/3X/1/1/11350a5bba6498e3a9ec98b845dabd033b527def.jpeg)

---

<div class="post-metadata">

**Author:** ![benelsen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benelsen/32/1620_2.png) [@benelsen](https://discourse.julialang.org/u/benelsen)\
**Post date:** [September 20, 2018, 8:21pm UTC](https://discourse.julialang.org/t/sun-symbol-with-latexstrings/15250/2 "2018-09-20T20:21:51Z")

</div>

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`:

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

```

![fig](https://global.discourse-cdn.com/julialang/original/3X/4/2/4204bebff87d120f70ba6fdd8fc7b69390242e24.png)

Might be a topic for [Visualization](https://discourse.julialang.org/c/domain/viz)

---

<div class="post-metadata">

**Author:** ![astrowanders](https://avatars.discourse-cdn.com/v4/letter/a/e47774/32.png) [@astrowanders](https://discourse.julialang.org/u/astrowanders)\
**Post date:** [September 20, 2018, 9:28pm UTC](https://discourse.julialang.org/t/sun-symbol-with-latexstrings/15250/3 "2018-09-20T21:28:09Z")

</div>

Thanks @benelsen!

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

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [September 21, 2018, 7:51am UTC](https://discourse.julialang.org/t/sun-symbol-with-latexstrings/15250/4 "2018-09-21T07:51:12Z")

</div>

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](https://github.com/jheinen/GR.jl/issues/93)

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [September 21, 2018, 8:18am UTC](https://discourse.julialang.org/t/sun-symbol-with-latexstrings/15250/5 "2018-09-21T08:18:05Z")

</div>

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

```julia
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](https://global.discourse-cdn.com/julialang/original/3X/4/3/439d65b289048f85e8fa25269964ee77aa7533c3.png)

---

<div class="post-metadata">

**Author:** ![astrowanders](https://avatars.discourse-cdn.com/v4/letter/a/e47774/32.png) [@astrowanders](https://discourse.julialang.org/u/astrowanders)\
**Post date:** [September 21, 2018, 3:12pm UTC](https://discourse.julialang.org/t/sun-symbol-with-latexstrings/15250/6 "2018-09-21T15:12:00Z")

</div>

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
