Skip to content

Commit

Permalink
refactor: add an optional argument to disable the display of open fig…
Browse files Browse the repository at this point in the history
…ures in plot_radial_profile() and allow for plot customisation through existing axes
  • Loading branch information
andizq committed Jun 10, 2024
1 parent 6243371 commit 3ee2bff
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions fil_finder/filament.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,17 +1122,25 @@ def radprof_model(self):
'''
return self._radprof_model

def plot_radial_profile(self, save_name=None, xunit=u.pix,
ax=None):
def plot_radial_profile(self,
ax=None,
save_name=None,
show_plot=True,
xunit=u.pix
):
'''
Plot the radial profile of the filament and the fitted model.
Parameters
----------
xunit : `~astropy.units.Unit`, optional
Pixel, angular, or physical unit to convert to.
ax : `~matplotlib.axes`, optional
Use an existing set of axes to plot the profile.
save_name : str, optional
Name of saved plot. A plot is only saved if a name is given.
show_plot : bool, optional
Display open figure.
xunit : `~astropy.units.Unit`, optional
Pixel, angular, or physical unit to convert to.
'''

dist, radprof = self.radprofile
Expand Down Expand Up @@ -1164,8 +1172,12 @@ def plot_radial_profile(self, save_name=None, xunit=u.pix,

if save_name is not None:
plt.savefig(save_name)

plt.show()
if not show_plot:
plt.close()

if show_plot:
plt.show()

if in_ipynb():
plt.clf()

Expand Down

0 comments on commit 3ee2bff

Please sign in to comment.