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

ENH: Optional argument to show the plot in Function.compare_plots #563

Merged
merged 2 commits into from
Feb 27, 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).


### Changed

- ENH: Optional argument to show the plot in Function.compare_plots [#563](https://github.com/RocketPy-Team/RocketPy/pull/563)

### Fixed
- BUG: export_eng 'Motor' method would not work for liquid motors. [#559](https://github.com/RocketPy-Team/RocketPy/pull/559)
Expand Down
41 changes: 24 additions & 17 deletions rocketpy/mathutils/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1474,45 +1474,51 @@ def compare_plots(
force_data=False,
force_points=False,
return_object=False,
show=True,
):
"""Plots N 1-Dimensional Functions in the same plot, from a lower
limit to an upper limit, by sampling the Functions several times in
the interval.

Parameters
----------
plot_list : list
plot_list : list[Tuple[Function,str]]
List of Functions or list of tuples in the format (Function,
label), where label is a string which will be displayed in the
legend.
lower : scalar, optional
The lower limit of the interval in which the Functions are to be
plotted. The default value for function type Functions is 0. By
contrast, if the Functions given are defined by a dataset, the
default value is the lowest value of the datasets.
upper : scalar, optional
The upper limit of the interval in which the Functions are to be
plotted. The default value for function type Functions is 10. By
contrast, if the Functions given are defined by a dataset, the
default value is the highest value of the datasets.
lower : float, optional
This represents the lower limit of the interval for plotting the
Functions. If the Functions are defined by a dataset, the smallest
value from the dataset is used. If no value is provided (None), and
the Functions are of Function type, 0 is used as the default.
upper : float, optional
This represents the upper limit of the interval for plotting the
Functions. If the Functions are defined by a dataset, the largest
value from the dataset is used. If no value is provided (None), and
the Functions are of Function type, 10 is used as the default.
samples : int, optional
The number of samples in which the functions will be evaluated for
plotting it, which draws lines between each evaluated point.
The default value is 1000.
title : string, optional
title : str, optional
Title of the plot. Default value is an empty string.
xlabel : string, optional
xlabel : str, optional
X-axis label. Default value is an empty string.
ylabel : string, optional
ylabel : str, optional
Y-axis label. Default value is an empty string.
force_data : Boolean, optional
force_data : bool, optional
If Function is given by an interpolated dataset, setting force_data
to True will plot all points, as a scatter, in the dataset.
Default value is False.
force_points : Boolean, optional
force_points : bool, optional
Setting force_points to True will plot all points, as a scatter, in
which the Function was evaluated to plot it. Default value is
False.
return_object : bool, optional
If True, returns the figure and axis objects. Default value is
False.
show : bool, optional
If True, shows the plot. Default value is True.

Returns
-------
Expand Down Expand Up @@ -1586,7 +1592,8 @@ def compare_plots(
plt.xlabel(xlabel)
plt.ylabel(ylabel)

plt.show()
if show:
plt.show()

if return_object:
return fig, ax
Expand Down