# Plotting markdown in the legend

**URL:** <https://discourse.julialang.org/t/plotting-markdown-in-the-legend/34637>\
**Category:** Visualization\
**Tags:** question, plotting, markdown\
**Created:** [February 14, 2020, 4:20pm UTC](https://discourse.julialang.org/t/plotting-markdown-in-the-legend/34637 "2020-02-14T16:20:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![crinders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/crinders/32/8434_2.png) [@crinders](https://discourse.julialang.org/u/crinders)\
**Post date:** [February 14, 2020, 4:20pm UTC](https://discourse.julialang.org/t/plotting-markdown-in-the-legend/34637/1 "2020-02-14T16:20:03Z")

</div>

I am trying to plot Markdown in the legend of a plot. According to this blog [post](https://tamaspapp.eu/post/plot-workflow/) by @Tamas_Papp `LaTeXStrings.jl` can be used to display latex math and that works, but when I want to typeset other LaTeX commands it doesn’t work (as pointed out in the documentation).  
So I try markdown

```julia
using Markdown
md"\$K_1\$ **hah**"

```

is properly rendered in jupyter, but the same for

```julia
using Plots
using Markdown
plot(rand(10),label=md"\$K_1\$ **hah**")

```

renders `$K_1$ **hah** ` instead of K\_1 **hah**.  
Similarly

```julia
using Plots
using LaTeXStrings
plot(rand(10),label=latexstring("\$K_1\$"))

```

renders correctly but

```julia
using Plots
using LaTeXStrings
plot(rand(10),label=latexstring("\$K_1\$ hah"))

```

does not.  
Is there a way to force the legend to display correctly?

---

<div class="post-metadata">

**Author:** ![pbayer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbayer/32/11675_2.png) [@pbayer](https://discourse.julialang.org/u/pbayer)\
**Post date:** [February 14, 2020, 5:27pm UTC](https://discourse.julialang.org/t/plotting-markdown-in-the-legend/34637/2 "2020-02-14T17:27:22Z")

</div>

how about:

```julia
plot(rand(10),label=latexstring("K_1\\, \\mathbf{hah}"))

```

---

<div class="post-metadata">

**Author:** ![crinders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/crinders/32/8434_2.png) [@crinders](https://discourse.julialang.org/u/crinders)\
**Post date:** [February 14, 2020, 6:55pm UTC](https://discourse.julialang.org/t/plotting-markdown-in-the-legend/34637/3 "2020-02-14T18:55:09Z")

</div>

It’s kludgy, but it works. I also needed textrm so I’ve done

```julia
plot(rand(10)=L"K_1\textrm{ Series {\bfseries 1}}")

```

The only downside to this is the weak contrast.
