Gnuplot.jl icon indicating copy to clipboard operation
Gnuplot.jl copied to clipboard

How to properly reset gnuplot from julia

Open aloispichler opened this issue 2 months ago • 1 comments

I use multiplot

	@gp "reset"

	@gp "set multiplot layout 1,2 title '$(tree.name)'" :-
	@gp :- 1 xlabel="stage" :-
	@gp :- 1 "set title 'trajectories'" :-
     etc.

but then I cannot reset the plot. I tried

	@gp :- "unset multiplot"
	@gp :- "reset"

and combinations as

	@gp :- 1 "unset multiplot"
	@gp :- 2 "reset"

but no success…

All commands fail, even @gp "reset session" fail with the same error (see below). What is the proper way of completely restarting, avoiding Gnuplot.quitall()?

Thank you!

PS: the error:

ERROR: BoundsError: attempt to access 0-element Vector{String} at index [1]
Stacktrace:
 [1] getindex
   @ ./essentials.jl:919 [inlined]
 [2] reset(gp::Gnuplot.GPSession)
   @ Gnuplot ~/.julia/packages/Gnuplot/jJ4hs/src/Gnuplot.jl:774
 [3] driver(::String, ::Vararg{Any}; is3d::Bool)
   @ Gnuplot ~/.julia/packages/Gnuplot/jJ4hs/src/Gnuplot.jl:1283
 [4] driver
   @ ~/.julia/packages/Gnuplot/jJ4hs/src/Gnuplot.jl:1261 [inlined]

aloispichler avatar Nov 21 '25 20:11 aloispichler

Typically you don't need to explicitly reset gnuplot since this operation is performed by Gnuplot.jl itself each time you invoke @gp without the leading :- symbol.

You can check the list of all commands sent to the underlying gnuplot process by setting:

Gnuplot.options.verbose = true

Among the commands, you'll see the reset session, unset multiplot and reset being sent whenever is necessary.

I am not able to reproduce the error you mentioned, can you please send a minimum list of lines which produces the error?

gcalderone avatar Nov 24 '25 08:11 gcalderone