Skip to content

Commit

Permalink
added figsize to method plot_trajectories
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter230655 committed Sep 4, 2024
1 parent 7e7921c commit 1af48c1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions opty/direct_collocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def plot_trajectories(self, vector, axes=None):

if axes is None:
fig, axes = plt.subplots(num_axes, 1, sharex=True,
layout='compressed')
layout='compressed', figsize=(6.4, 0.8*num_axes))

for ax, traj, symbol in zip(axes, trajectories, traj_syms):
ax.plot(time, traj)
Expand Down Expand Up @@ -440,13 +440,16 @@ def plot_constraint_violations(self, vector, axes=None):
axes : ndarray of AxesSubplot
A matplotlib axes with the constraint violations plotted.
If axes are given by the user:
The number of axes needed is calculated like this:
len(axes) = 2 if len(self.collocator.instance_constraints) <= bars_per_plot.
len(axes) = len(self.collocator.instance_constraints) // bars_per_plot + 2
if len(self.collocator.instance_constraints) % bars_per_plot != 0.
len(axes) = len(self.collocator.instance_constraints) // bars_per_plot + 1
if len(self.collocator.instance_constraints) % bars_per_plot = 0.
If the uses gives at least two axis, the method will tell the user
how many are needed, unless the correct amount is given.
Notes
=====
Expand Down Expand Up @@ -516,8 +519,9 @@ def plot_constraint_violations(self, vector, axes=None):
num_inst_viols = len(instance_violations)

if axes is None:
fig, axes = plt.subplots(1 + num_plots, squeeze=False,
layout='compressed', figsize=(8, 2.0*(num_plots+1)))
fig, axes = plt.subplots(1 + num_plots, 1,
figsize=(6.4, 1.50*(1 + num_plots)),
layout='compressed')

axes = axes.ravel()

Expand Down

0 comments on commit 1af48c1

Please sign in to comment.