PlutoPlotly: save a plot with LaTeX strings

VivMendes
Tue, 13 Feb 2024 17:15:31 +0000
General Usage

Hi,

I can produce a plot in Pluto with some LaTeX ingredients using PlutoPlotly and LaTexStrings (which is not possible to achieve to the best of my knowledge using PlotlyJS). The plot is perfectly rendered in the notebook’s active and static versions, and the LaTeX strings are correctly displayed.

However, when I try to save it as a PDF, SVG, or PNG file, the LaTeX output is gone (please see the images below). Is there any way we can overcome this problem by using Pluto? @jd-foster seems to propose a way out of this problem here. I tried it, but I was not successful.

Thanks.

MWE: Julia 1.10.0, PlutoPlotly 0.4.4, Pluto 0.19.38, PlotlyJS 0.18.12.

begin
	using PlutoUI ,  PlutoPlotly , LaTeXStrings
	import PlotlyJS: savefig

	fig2 = plot(1:300, [randn(300) randn(300)])

	relayout!(fig2,
		height = 450,
		title_text = L"\text{A title with some LaTeX:} \sum \beta^i x_{t-i}", title_x = 0.5,
		hovermode = "x",
		yaxis_title = L"y(t), x(t)",
		xaxis_title = L"t",
		xaxis_range=[-10 , 310])

	restyle!(fig2,
		name = [L"\sigma^2_x = 1" , L"\sigma^2_y = 1"],
		mode="markers+lines", line_width = 0.3, line_color = ["RoyalBlue", "Maroon"])

	fig2

	savefig(fig2.Plot, "fig2.pdf", width = 1000)
end

Output in the notebook:

Saved pdf figure:

4 posts - 2 participants