Currently it doesn’t work in the Juno IDE, but it does work in IJulia, if you copy the correct fonts to the mathjax directory:
- Download MathJax-2.7.7.zip
- copy the
jax
-folder toC:\Users\<username>\.julia\conda\3\Lib\site-packages\notebook\static\components\MathJax
or wherever this is on your system. Note that there might be more MathJax folders, (e.g.C:\Users\<username>\.julia\conda\3\pkgs\notebook-6.0.3-py36_0\Lib\site-packages\notebook\static\components\MathJax
, but only one is the true source for the server.
The background seems to be that Mathjax changed the default font to TeX, but the current distribution that comes with Jupyter only contains Stix-Web. I have posted this recently on stackoverflow.
using Plots, LaTeXStrings
plotly()
Plots.plot(1:4, [[1,4,9,16], [0.5, 2, 4.5, 8]],
labels = [L"\alpha_{1c} = 352 \pm 11 \text{ km s}^{-1}" L"\beta_{1c} = 25 \pm 11 \text{ km s}^{-1}"],
xlabel = L"\sqrt{(n_\text{c}(t|{T_\text{early}}))}",
ylabel = L"d, r \text{ (solar radius)}"
)
produces
EDIT:
The following lines make it available in Juno. Make sure, Conda is installed and the files are copied as described above.
using Plots, LaTeXStrings
plotly()
import Plots.plotly_html_head
import Conda.ROOTENV
function mathjax()
mathjaxdir = joinpath(ROOTENV, "Lib\\site-packages\\notebook\\static\\components\\MathJax")
mathjaxfile = joinpath(mathjaxdir, "MathJax.js?config=TeX-AMS-MML_HTMLorMML-full")
return """<script type="text/javascript" src="$mathjaxfile"></script>"""
end
function Plots.plotly_html_head(plt::Plots.Plot)
local_file = ("file://" * Plots.plotly_local_file_path)
plotly = Plots.use_local_dependencies[] ? Plots.local_file : Plots.plotly_remote_file_path
if Plots.isijulia() && !Plots.ijulia_initialized[]
# using requirejs seems to be key to load a js depency in IJulia!
# https://requirejs.org/docs/start.html
# https://github.com/JuliaLang/IJulia.jl/issues/345
display("text/html", """
<script type="text/javascript">
requirejs([$(repr(plotly))], function(p) {
window.Plotly = p
});
</script>
""")
ijulia_initialized[] = true
end
return """$(mathjax())
<script src=$(repr(plotly))></script>"""
end