@@ -231,7 +231,7 @@ function __initial_plot(
231231 :control ∈ description && push! (plots, Plots. plot ()) # control
232232 :control ∈ description && push! (plots, Plots. plot ()) # control norm
233233 if length (plots) == 4
234- return Plots. plot (plots... ; layout= (2 , 2 ), bottommargin = 5 mm, kwargs... )
234+ return Plots. plot (plots... ; layout= (2 , 2 ), kwargs... )
235235 else
236236 return Plots. plot (plots... ; layout= (1 , length (plots)), bottommargin= 5 mm, kwargs... )
237237 end
@@ -256,6 +256,9 @@ function __initial_plot(
256256 :costate ∈ description && push! (costate_plots, PlotLeaf ())
257257 end
258258
259+ println (" state_plots: " , state_plots)
260+ println (" costate_plots: " , costate_plots)
261+
259262 # create the control plots
260263 if :control ∈ description
261264 l = m
@@ -284,10 +287,6 @@ function __initial_plot(
284287 end
285288 end
286289
287- # starting root
288- root = EmptyPlot ()
289- nblines = 0
290-
291290 # assemble the state and costate plots
292291 node_x = isempty (state_plots) ? EmptyPlot () : PlotNode (:column , state_plots)
293292 node_p = isempty (costate_plots) ? EmptyPlot () : PlotNode (:column , costate_plots)
@@ -301,6 +300,8 @@ function __initial_plot(
301300 node_u = isempty (control_plots) ? EmptyPlot () : PlotNode (:column , control_plots)
302301
303302 # create the root node
303+ root = EmptyPlot ()
304+ nblines = 0
304305 if ( ! (node_xp isa EmptyPlot) && ! (node_u isa EmptyPlot) )
305306 nblines = n + l
306307 a = __height (round (n / nblines; digits= 2 ))
@@ -309,9 +310,12 @@ function __initial_plot(
309310 b
310311 ]
311312 root = PlotNode (lay, [node_xp, node_u])
312- else
313- root = node_xp isa EmptyPlot ? node_u : node_xp
314- nblines = node_xp isa EmptyPlot ? l : n
313+ elseif ! (node_xp isa EmptyPlot)
314+ root = node_xp
315+ nblines = n
316+ elseif ! (node_u isa EmptyPlot)
317+ root = node_u
318+ nblines = l
315319 end
316320
317321 # Add the path constraints and their dual variables (in two columns as for state and costate) plots
@@ -336,8 +340,9 @@ function __initial_plot(
336340 end
337341
338342 # update the root node
339- if ! (node_cocp isa EmptyPlot)
340- c = __height (round (nc / (nblines + nc); digits= 2 ))
343+ if ! (node_cocp isa EmptyPlot)
344+ nblines += nc
345+ c = __height (round (nc / nblines; digits= 2 ))
341346 @eval lay = @layout [
342347 a
343348 $ c
@@ -347,7 +352,7 @@ function __initial_plot(
347352 end
348353
349354 # plot
350- return __plot_tree (root; kwargs... )
355+ return nblines == 1 ? __plot_tree (root; bottommargin = 5 mm, kwargs ... ) : __plot_tree (root; kwargs... )
351356
352357 else
353358 throw (CTBase. IncorrectArgument (" No such choice for layout. Use :group or :split" ))
0 commit comments