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

Propagate plotting keywords in Potential.plot/plotPotentials #663

Merged
merged 1 commit into from
Jul 9, 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
1 change: 1 addition & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
v1.10.1 (Expected around 2024-11-01)
====================

- Propagate general plotting keywords in Potential.plot/plotPotentials.

v1.10.0 (2024-07-07)
====================
Expand Down
18 changes: 14 additions & 4 deletions galpy/potential/Potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ def plot(
cntrcolors=None,
ncontours=21,
savefilename=None,
**kwargs,
):
"""
Plot the potential.
Expand Down Expand Up @@ -959,6 +960,8 @@ def plot(
Colors of the contours (single color or array with length ncontours). Default is None.
ncontours : int, optional
Number of contours when levels is None. Default is 21.
**kwargs : dict, optional
Any additional keyword arguments are passed to `galpy.util.plot.dens2d`.

Returns
-------
Expand All @@ -968,6 +971,7 @@ def plot(
-----
- 2010-07-09 - Written - Bovy (NYU)
- 2014-04-08 - Added effective= - Bovy (IAS)
- 2024-07-09 - Propagate other plotting keywords - Bovy (UofT)

"""
if effective and xy:
Expand All @@ -981,7 +985,7 @@ def plot(
xrange = [rmin, rmax]
if yrange is None:
yrange = [zmin, zmax]
if not savefilename is None and os.path.exists(savefilename):
if savefilename is not None and os.path.exists(savefilename):
print("Restoring savefile " + savefilename + " ...")
savefile = open(savefilename, "rb")
potRz = pickle.load(savefile)
Expand Down Expand Up @@ -1012,7 +1016,7 @@ def plot(
potRz[:, zs > zmax] = numpy.nan
# Infinity is bad for plotting
potRz[~numpy.isfinite(potRz)] = numpy.nan
if not savefilename == None:
if savefilename is not None:
print("Writing savefile " + savefilename + " ...")
savefile = open(savefilename, "wb")
pickle.dump(potRz, savefile)
Expand Down Expand Up @@ -1043,6 +1047,7 @@ def plot(
justcontours=justcontours,
levels=levels,
cntrcolors=cntrcolors,
**kwargs,
)

def plotDensity(
Expand Down Expand Up @@ -2766,6 +2771,7 @@ def plotPotentials(
justcontours=False,
levels=None,
cntrcolors=None,
**kwargs,
):
"""
Plot a set of potentials.
Expand Down Expand Up @@ -2812,6 +2818,8 @@ def plotPotentials(
Save to or restore from this savefile (pickle). Default is None.
aspect : float, optional
Aspect ratio of the plot. Default is None.
**kwargs : dict, optional
Any additional keyword arguments are passed to `galpy.util.plot.dens2d`.

Returns
-------
Expand All @@ -2820,6 +2828,7 @@ def plotPotentials(
Notes
-----
- 2010-07-09 - Written by Bovy (NYU).
- 2024-07-09 - Propagate keyword arguments to `galpy.util.plot.dens2d` - Bovy (UofT)

See Also
--------
Expand All @@ -2838,7 +2847,7 @@ def plotPotentials(
xrange = [rmin, rmax]
if yrange is None:
yrange = [zmin, zmax]
if not savefilename == None and os.path.exists(savefilename):
if savefilename is not None and os.path.exists(savefilename):
print("Restoring savefile " + savefilename + " ...")
savefile = open(savefilename, "rb")
potRz = pickle.load(savefile)
Expand Down Expand Up @@ -2869,7 +2878,7 @@ def plotPotentials(
potRz[:, zs > zmax] = numpy.nan
# Infinity is bad for plotting
potRz[~numpy.isfinite(potRz)] = numpy.nan
if not savefilename == None:
if savefilename is not None:
print("Writing savefile " + savefilename + " ...")
savefile = open(savefilename, "wb")
pickle.dump(potRz, savefile)
Expand Down Expand Up @@ -2902,6 +2911,7 @@ def plotPotentials(
justcontours=justcontours,
levels=levels,
cntrcolors=cntrcolors,
**kwargs,
)


Expand Down
Loading