Skip to content

Commit 9116741

Browse files
authored
Update manual-plot.html
1 parent 6d5c297 commit 9116741

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

v1.1.3/manual-plot.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@
331331
end
332332
sol2 = solve(ocp; display=false)</code></pre><p>We first plot the solution of the first optimal control problem, then, we plot the solution of the second optimal control problem on the same figure, but with dashed lines.</p><pre><code class="language-julia hljs">plt = plot(sol; label=&quot;sol1&quot;, size=(700, 500))
333333
plot!(plt, sol2; label=&quot;sol2&quot;, linestyle=:dash)</code></pre><img src="manual-plot-90a8d66e.svg" alt="Example block output"/><p>You can also, implicitely, use the current plot.</p><pre><code class="language-julia hljs">plot(sol; label=&quot;sol1&quot;, size=(700, 500))
334-
plot!(sol2; label=&quot;sol2&quot;, linestyle=:dash)</code></pre><img src="manual-plot-30cfaa37.svg" alt="Example block output"/><h2 id="manual-plot-control"><a class="docs-heading-anchor" href="#manual-plot-control">Plotting the control norm</a><a id="manual-plot-control-1"></a><a class="docs-heading-anchor-permalink" href="#manual-plot-control" title="Permalink"></a></h2><p>For some problem, it is interesting to plot the (Euclidean) norm of the control. You can do it by using the <code>control</code> optional keyword argument with <code>:norm</code> value.</p><pre><code class="language-julia hljs">plot(sol; control=:norm, size=(800, 300), layout=:group)</code></pre><img src="manual-plot-5e4c1482.svg" alt="Example block output"/><p>The default value is <code>:components</code>.</p><pre><code class="language-julia hljs">plot(sol; control=:components, size=(800, 300), layout=:group)</code></pre><img src="manual-plot-4f358e6a.svg" alt="Example block output"/><p>You can also plot the control and is norm.</p><pre><code class="language-julia hljs">plot(sol; control=:all, layout=:group)</code></pre><img src="manual-plot-821474a9.svg" alt="Example block output"/><h2 id="manual-plot-custom"><a class="docs-heading-anchor" href="#manual-plot-custom">Custom plot and subplots</a><a id="manual-plot-custom-1"></a><a class="docs-heading-anchor-permalink" href="#manual-plot-custom" title="Permalink"></a></h2><p>You can, of course, create your own plots by extracting the <code>state</code>, <code>costate</code>, and <code>control</code> from the optimal control solution. For instance, let us plot the norm of the control.</p><pre><code class="language-julia hljs">using LinearAlgebra
334+
plot!(sol2; label=&quot;sol2&quot;, linestyle=:dash)</code></pre><img src="manual-plot-30cfaa37.svg" alt="Example block output"/><h2 id="manual-plot-control"><a class="docs-heading-anchor" href="#manual-plot-control">Plotting the control norm</a><a id="manual-plot-control-1"></a><a class="docs-heading-anchor-permalink" href="#manual-plot-control" title="Permalink"></a></h2><p>For some problem, it is interesting to plot the (Euclidean) norm of the control. You can do it by using the <code>control</code> optional keyword argument with <code>:norm</code> value.</p><pre><code class="language-julia hljs">plot(sol; control=:norm, size=(800, 300), layout=:group)</code></pre><img src="manual-plot-5e4c1482.svg" alt="Example block output"/><p>The default value is <code>:components</code>.</p><pre><code class="language-julia hljs">plot(sol; control=:components, size=(800, 300), layout=:group)</code></pre><img src="manual-plot-4f358e6a.svg" alt="Example block output"/><p>You can also plot the control and its norm.</p><pre><code class="language-julia hljs">plot(sol; control=:all, layout=:group)</code></pre><img src="manual-plot-821474a9.svg" alt="Example block output"/><h2 id="manual-plot-custom"><a class="docs-heading-anchor" href="#manual-plot-custom">Custom plot and subplots</a><a id="manual-plot-custom-1"></a><a class="docs-heading-anchor-permalink" href="#manual-plot-custom" title="Permalink"></a></h2><p>You can, of course, create your own plots by extracting the <code>state</code>, <code>costate</code>, and <code>control</code> from the optimal control solution. For instance, let us plot the norm of the control.</p><pre><code class="language-julia hljs">using LinearAlgebra
335335
t = time_grid(sol)
336336
u = control(sol)
337337
plot(t, norm∘u; label=&quot;‖u‖&quot;, xlabel=&quot;t&quot;)</code></pre><img src="manual-plot-192ff237.svg" alt="Example block output"/><p>You can also get access to the subplots. The order is as follows: state, costate, control, path constraints (if any) and their dual variables.</p><pre><code class="language-julia hljs">plt = plot(sol)

0 commit comments

Comments
 (0)