KristofferC / PGFPlotsX.jl

Plots in Julia using the PGFPlots LaTeX package
Other
301 stars 40 forks source link

`sp_width` is undefined #303

Closed JamieMair closed 2 years ago

JamieMair commented 2 years ago

Issue when setting a title for a subplot using Plots.jl:

using Plots
pgfplotsx()

plt1 = plot(rand(100, 5))
plt2 = plot(rand(100))
plt3 = plot(rand(100))

plot(plt1, plt2, plt3, layout=(1,3), plot_titles=["(a)" "(b)" "(c)"])

Error stacktrace:

ERROR: UndefVarError: sp_width not defined
Stacktrace:
  [1] (::Plots.PGFPlotsXPlot)(plt::Plots.Plot{Plots.PGFPlotsXBackend})
    @ Plots ~/.julia/packages/Plots/lW9ll/src/backends/pgfplotsx.jl:120
  [2] _update_plot_object(plt::Plots.Plot{Plots.PGFPlotsXBackend})
    @ Plots ~/.julia/packages/Plots/lW9ll/src/backends/pgfplotsx.jl:1359

Proposed in pgfplotsx.jl:

sp_w, sp_h = width(bb2), height(bb2)
if sp[:subplot_index] == plt[:plot_titleindex]
    x = dx + sp_width / 2 - 10mm  # FIXME: get rid of magic constant
    y = dy + sp_height / 2
   # ..etc

to:

sp_w, sp_h = width(bb2), height(bb2)
if sp[:subplot_index] == plt[:plot_titleindex]
    x = dx + sp_w/ 2 - 10mm  # FIXME: get rid of magic constant
    y = dy + sp_h/ 2
   # ..etc
JamieMair commented 2 years ago

Wrong library! Sorry!