You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
evaluated at all points in the list and a list of floats will be
1089
1091
returned. If the function is N-D, N arguments must be given, each
1090
1092
one being an scalar or list.
1093
+
filename : str | None, optional
1094
+
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
Function.plot_2d if Function is 2-Dimensional and forward arguments
1156
1160
and key-word arguments."""
1157
1161
ifisinstance(self, list):
1162
+
# Extract filename from kwargs
1163
+
filename=kwargs.get("filename", None)
1164
+
1158
1165
# Compare multiple plots
1159
-
Function.compare_plots(self)
1166
+
Function.compare_plots(self, filename)
1160
1167
else:
1161
1168
ifself.__dom_dim__==1:
1162
1169
self.plot_1d(*args, **kwargs)
@@ -1184,6 +1191,7 @@ def plot_1d(
1184
1191
force_points=False,
1185
1192
return_object=False,
1186
1193
equal_axis=False,
1194
+
filename=None,
1187
1195
):
1188
1196
"""Plot 1-Dimensional Function, from a lower limit to an upper limit,
1189
1197
by sampling the Function several times in the interval. The title of
@@ -1214,6 +1222,8 @@ def plot_1d(
1214
1222
Setting force_points to True will plot all points, as a scatter, in
1215
1223
which the Function was evaluated in the dataset. Default value is
1216
1224
False.
1225
+
filename : str | None, optional
1226
+
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
1217
1227
1218
1228
Returns
1219
1229
-------
@@ -1254,7 +1264,7 @@ def plot_1d(
1254
1264
plt.title(self.title)
1255
1265
plt.xlabel(self.__inputs__[0].title())
1256
1266
plt.ylabel(self.__outputs__[0].title())
1257
-
plt.show()
1267
+
show_or_save_plot(filename)
1258
1268
ifreturn_object:
1259
1269
returnfig, ax
1260
1270
@@ -1277,6 +1287,7 @@ def plot_2d(
1277
1287
disp_type="surface",
1278
1288
alpha=0.6,
1279
1289
cmap="viridis",
1290
+
filename=None,
1280
1291
):
1281
1292
"""Plot 2-Dimensional Function, from a lower limit to an upper limit,
1282
1293
by sampling the Function several times in the interval. The title of
@@ -1316,6 +1327,8 @@ def plot_2d(
1316
1327
cmap : string, optional
1317
1328
Colormap of plotted graph, which can be any of the color maps
1318
1329
available in matplotlib. Default value is viridis.
1330
+
filename : str | None, optional
1331
+
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
1319
1332
1320
1333
Returns
1321
1334
-------
@@ -1389,7 +1402,7 @@ def plot_2d(
1389
1402
axes.set_xlabel(self.__inputs__[0].title())
1390
1403
axes.set_ylabel(self.__inputs__[1].title())
1391
1404
axes.set_zlabel(self.__outputs__[0].title())
1392
-
plt.show()
1405
+
show_or_save_plot(filename)
1393
1406
1394
1407
@staticmethod
1395
1408
defcompare_plots(
@@ -1404,6 +1417,7 @@ def compare_plots(
1404
1417
force_points=False,
1405
1418
return_object=False,
1406
1419
show=True,
1420
+
filename=None,
1407
1421
):
1408
1422
"""Plots N 1-Dimensional Functions in the same plot, from a lower
1409
1423
limit to an upper limit, by sampling the Functions several times in
@@ -1448,6 +1462,8 @@ def compare_plots(
1448
1462
False.
1449
1463
show : bool, optional
1450
1464
If True, shows the plot. Default value is True.
1465
+
filename : str | None, optional
1466
+
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
610
+
611
+
Returns
612
+
-------
613
+
None
614
+
"""
615
+
self.plots.draw(filename)
616
+
617
+
definfo(self, filename=None):
618
+
"""Prints out basic data about the Motor.
619
+
620
+
Parameters
621
+
----------
622
+
filename : str | None, optional
623
+
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
"""Prints out a summary of the data and graphs available about the
1040
1040
Motor.
1041
+
1042
+
Parameters
1043
+
----------
1044
+
filename : str | None, optional
1045
+
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
Copy file name to clipboardExpand all lines: rocketpy/motors/solid_motor.py
+13-3Lines changed: 13 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -699,9 +699,19 @@ def propellant_I_13(self):
699
699
defpropellant_I_23(self):
700
700
return0
701
701
702
-
defdraw(self):
703
-
"""Draw a representation of the SolidMotor."""
704
-
self.plots.draw()
702
+
defdraw(self, filename=None):
703
+
"""Draw a representation of the SolidMotor.
704
+
705
+
Parameters
706
+
----------
707
+
filename : str | None, optional
708
+
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
"""Draw the nosecone shape along with some important information,
75
77
including the center line and the center of pressure position.
76
78
79
+
Parameters
80
+
----------
81
+
filename : str | None, optional
82
+
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
"""Draw the fin shape along with some important information, including
238
245
the center line, the quarter line and the center of pressure position.
239
246
247
+
Parameters
248
+
----------
249
+
filename : str | None, optional
250
+
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
"""Draw the fin shape along with some important information.
363
375
These being: the center line and the center of pressure position.
364
376
377
+
Parameters
378
+
----------
379
+
filename : str | None, optional
380
+
The path the plot should be saved to. By default None, in which case the plot will be shown instead of saved. Supported file endings are: eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff and webp.
0 commit comments