Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where matplotlib was not required to install dymos without specifications but would fail to import. #1035

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions dymos/examples/brachistochrone/test/ex_brachistochrone.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import matplotlib
import numpy as np

import openmdao.api as om
Expand All @@ -8,10 +7,6 @@
from dymos.examples.brachistochrone.brachistochrone_ode import BrachistochroneODE


SHOW_PLOTS = True
matplotlib.use('Agg')


@require_pyoptsparse(optimizer='SLSQP')
def brachistochrone_min_time(transcription='gauss-lobatto', num_segments=8, transcription_order=3,
compressed=True, optimizer='SLSQP', run_driver=True, force_alloc_complex=False,
Expand Down
7 changes: 4 additions & 3 deletions dymos/examples/cart_pole/animate_cartpole.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib import animation


def animate_cartpole(x, theta, force, interval=20, force_scaler=0.1, save_gif=False, gif_fps=20):

import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib import animation
# x: time history of cart location, 1d vector
# theta: time history of pole angle, 1d vector
# force: control input force
Expand Down
5 changes: 2 additions & 3 deletions dymos/examples/plotting.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import matplotlib.pyplot as plt


def plot_results(axes, title, figsize=(10, 8), p_sol=None, p_sim=None):
"""
Plot the timeseries results of a Dymos problem using matplotlib.
Expand All @@ -22,6 +19,8 @@ def plot_results(axes, title, figsize=(10, 8), p_sol=None, p_sim=None):
The Figure object and sequence of axes associated with the plot.

"""
import matplotlib.pyplot as plt

nrows = len(axes)

fig, axs = plt.subplots(nrows=nrows, ncols=1, figsize=figsize)
Expand Down
10 changes: 5 additions & 5 deletions dymos/visualization/timeseries_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

import numpy as np

import matplotlib
import matplotlib.pyplot as plt
import matplotlib.lines as mlines
import matplotlib.patches as mpatches

import openmdao.api as om
from .._options import options as dymos_options

Expand Down Expand Up @@ -55,6 +50,11 @@ def _get_phases_node_in_problem_metadata(node, path=""):
def _mpl_timeseries_plots(time_units, var_units, phase_names, phases_node_path,
last_solution_case, last_simulation_case, plot_dir_path,
dpi, include_parameters):
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.lines as mlines
import matplotlib.patches as mpatches

# get ready to plot
backend_save = plt.get_backend()
plt.switch_backend('Agg')
Expand Down