# LaTeX Support for Interactive Plotting

**URL:** <https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565>\
**Category:** New to Julia\
**Created:** [July 28, 2024, 12:34pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565 "2024-07-28T12:34:15Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ckawa](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@ckawa](https://discourse.julialang.org/u/ckawa)\
**Post date:** [July 28, 2024, 12:34pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/1 "2024-07-28T12:34:15Z")

</div>

Just jumped into Julia from MATLAB so I’ve been spoiled with nice plotting experience, but I want to transition workflows into Julia for academic research.

For plotting, I noticed that using LaTeXStrings works well for creating static plots, but when I try to do interactive plots (panning, cropping, zooming, etc) using various backends (PlotLy, Plotlygs) the latex formatting falls off.

I’ve seen other posts regarding this, but they are dated (~2020). Does any know if a solution or a workout has been established for this shorftall of Julia?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 28, 2024, 1:16pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/2 "2024-07-28T13:16:01Z")

</div>

I am old-fashioned and use [GitHub - JuliaPy/PyPlot.jl: Plotting for Julia based on matplotlib.pyplot](https://github.com/JuliaPy/PyPlot.jl) or [GitHub - aenarete/ControlPlots.jl: Create plots that can be saved and edited with Julia](https://github.com/aenarete/ControlPlots.jl) .

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [July 28, 2024, 1:37pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/3 "2024-07-28T13:37:09Z")

</div>

Makie does interactive plots with LaTeXStrings but like in most other packages it’s not real LaTeX but an approximation through MathTeXEngine.jl

On the other hand, if it was real LaTeX it wouldn’t be fast enough for interactivity anyway.

---

<div class="post-metadata">

**Author:** ![ckawa](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@ckawa](https://discourse.julialang.org/u/ckawa)\
**Post date:** [July 28, 2024, 5:42pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/4 "2024-07-28T17:42:26Z")

</div>

Thank you all! I understand that my request may be unreasonable to ask Julia to do exactly what I am used to in other languages.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 28, 2024, 5:46pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/5 "2024-07-28T17:46:50Z")

</div>

What are you missing? [Welcome to Makie! | Makie](https://docs.makie.org/stable/) and ControlPlots.jl both support LaTeX, zooming and panning, Makie being very powerful, my ControlPlots package being very simple and easy to use.

---

<div class="post-metadata">

**Author:** ![ckawa](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@ckawa](https://discourse.julialang.org/u/ckawa)\
**Post date:** [July 28, 2024, 7:21pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/6 "2024-07-28T19:21:03Z")

</div>

Thanks for replying. Again, I acknowledge this may be unreasonably particular, but I was looking for exact LaTeX formatting with dynamic plotting interface.

I’ve uploaded an example of plot font froM Control Plots vs MATLAB’s LaTeX rendering:  
 ![Screenshot 2024-07-28 at 15.20.28](https://global.discourse-cdn.com/julialang/original/3X/f/6/f6cfd17f50482f0d2f1af2b15835e69ca76900af.png)

---

<div class="post-metadata">

**Author:** ![ckawa](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@ckawa](https://discourse.julialang.org/u/ckawa)\
**Post date:** [July 28, 2024, 7:21pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/7 "2024-07-28T19:21:37Z")

</div>

here’s Control Plot’s. Again, I’m not trying to complain about anything - just wondering of what are the capabilities and limitations of Julia compared to what I’m used to.  
 ![Screenshot 2024-07-28 at 15.20.33](https://global.discourse-cdn.com/julialang/original/3X/e/9/e9e6947c21a4b617ee540ae78e3e82af3b978029.png)

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 28, 2024, 7:22pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/8 "2024-07-28T19:22:36Z")

</div>

Can you share the LaTeX source code?

---

<div class="post-metadata">

**Author:** ![ckawa](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@ckawa](https://discourse.julialang.org/u/ckawa)\
**Post date:** [July 28, 2024, 7:25pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/9 "2024-07-28T19:25:54Z")

</div>

Sure! From MATLAB:

```julia
xlabel("$\hat{P}$", "Interpreter", "latex", "FontSize", 20);

```

where that is attached to whatever plot you want. Here’s what I tried in Julia:

```julia
using ControlPlots, LaTeXStrings
plot(X, Y, xlabel=L"\hat{P}", fig="basic")

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 28, 2024, 7:32pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/10 "2024-07-28T19:32:41Z")

</div>

Did you try to export the figure in pdf format? Looks much better to me.  
 ![P](https://global.discourse-cdn.com/julialang/original/3X/3/7/379e19c2ec5990c626ed4d87bbbbc99188368962.png)

And you can also get high quality screen rendering if you add this:

```julia
rcParams = plt.PyDict(plt.matplotlib."rcParams")
rcParams["text.usetex"] = true

```

to the beginning of your script, but that requires that you have LaTeX installed locally on your machine.

---

<div class="post-metadata">

**Author:** ![ckawa](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@ckawa](https://discourse.julialang.org/u/ckawa)\
**Post date:** [July 28, 2024, 7:44pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/11 "2024-07-28T19:44:11Z")

</div>

Thanks for checking! I noticed that, in fact, using Plots.jl renders the PDF of exact LaTeX (or at least, close enough to me). However it’s not quite the exact same font for the dynamic/interactive plotting environment.

As @jules pointed out, the exact LaTeX for match may be too much for dynamic plot interaction. This by far not a deal-breaker for me and I know it’s probably falls under the “splitting hairs” category. But just something I’ve noticed and wondering if there was an exact.

Would I spend all the money for MATLAB’s license just for a font rendering? No.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 28, 2024, 7:45pm UTC](https://discourse.julialang.org/t/latex-support-for-interactive-plotting/117565/12 "2024-07-28T19:45:39Z")

</div>

> [@ckawa](#):
>
> Would I spend all the money for MATLAB’s license just for a font rendering? No.

All possible for free, see update of my last post. Just a little bit more hassle to install.
