Skip to content

Commit 75bc9e7

Browse files
committed
New eig plotting params
1 parent 0504e62 commit 75bc9e7

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

pydmd/bopdmd.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,15 +1505,22 @@ def plot_mode_uq(
15051505
def plot_eig_uq(
15061506
self,
15071507
eigs_true=None,
1508+
xlim=None,
1509+
ylim=None,
15081510
figsize=None,
15091511
dpi=None,
15101512
flip_axes=False,
1513+
draw_axes=False,
15111514
):
15121515
"""
15131516
Plot BOP-DMD eigenvalues against 1 and 2 standard deviations.
15141517

15151518
:param eigs_true: True continuous-time eigenvalues, if known.
15161519
:type eigs_true: np.ndarray
1520+
:param xlim: Desired limits for the x-axis.
1521+
:type xlim: iterable
1522+
:param ylim: Desired limits for the y-axis.
1523+
:type ylim: iterable
15171524
:param figsize: Width, height in inches.
15181525
:type figsize: iterable
15191526
:param dpi: Figure resolution.
@@ -1522,6 +1529,8 @@ def plot_eig_uq(
15221529
on the eigenvalue plot. If `True`, the real axis will be vertical
15231530
and the imaginary axis will be horizontal.
15241531
:type flip_axes: bool
1532+
:param draw_axes: Whether or not to draw the real and imaginary axes.
1533+
:type draw_axes: bool
15251534
"""
15261535

15271536
if self.eigenvalues_std is None:
@@ -1530,16 +1539,24 @@ def plot_eig_uq(
15301539
fig, ax = plt.subplots(figsize=figsize, dpi=dpi)
15311540
plt.title("DMD Eigenvalues")
15321541

1542+
if draw_axes:
1543+
ax.axhline(y=0, c="k")
1544+
ax.axvline(x=0, c="k")
1545+
15331546
if flip_axes:
15341547
eigs = self.eigs.imag + 1j * self.eigs.real
15351548
plt.xlabel("$Im(\omega)$")
15361549
plt.ylabel("$Re(\omega)$")
1550+
1551+
if eigs_true is not None:
1552+
eigs_true = eigs_true.imag + 1j * eigs_true.real
1553+
15371554
else:
15381555
eigs = self.eigs
15391556
plt.xlabel("$Re(\omega)$")
15401557
plt.ylabel("$Im(\omega)$")
15411558

1542-
for e, std in zip(self.eigs, self.eigenvalues_std):
1559+
for e, std in zip(eigs, self.eigenvalues_std):
15431560
# Plot 2 standard deviations.
15441561
c_1 = plt.Circle((e.real, e.imag), 2 * std, color="b", alpha=0.2)
15451562
ax.add_patch(c_1)
@@ -1552,14 +1569,12 @@ def plot_eig_uq(
15521569

15531570
# Plot the true eigenvalues if given.
15541571
if eigs_true is not None:
1555-
if flip_axes:
1556-
ax.plot(
1557-
eigs_true.imag, eigs_true.real, "x", c="k", label="Truth"
1558-
)
1559-
else:
1560-
ax.plot(
1561-
eigs_true.real, eigs_true.imag, "x", c="k", label="Truth"
1562-
)
1572+
ax.plot(eigs_true.real, eigs_true.imag, "x", c="k", label="Truth")
1573+
1574+
if xlim is not None:
1575+
ax.set_xlim(xlim)
1576+
if ylim is not None:
1577+
ax.set_ylim(ylim)
15631578

15641579
plt.legend()
15651580
plt.show()

0 commit comments

Comments
 (0)