Skip to content

Commit fca5c62

Browse files
committed
Propagate plotting keywords in Potential.plot/plotPotentials
1 parent 5f79ad0 commit fca5c62

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

galpy/potential/Potential.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ def plot(
917917
cntrcolors=None,
918918
ncontours=21,
919919
savefilename=None,
920+
**kwargs,
920921
):
921922
"""
922923
Plot the potential.
@@ -959,6 +960,8 @@ def plot(
959960
Colors of the contours (single color or array with length ncontours). Default is None.
960961
ncontours : int, optional
961962
Number of contours when levels is None. Default is 21.
963+
**kwargs : dict, optional
964+
Any additional keyword arguments are passed to `galpy.util.plot.dens2d`.
962965
963966
Returns
964967
-------
@@ -968,6 +971,7 @@ def plot(
968971
-----
969972
- 2010-07-09 - Written - Bovy (NYU)
970973
- 2014-04-08 - Added effective= - Bovy (IAS)
974+
- 2024-07-09 - Propagate other plotting keywords - Bovy (UofT)
971975
972976
"""
973977
if effective and xy:
@@ -981,7 +985,7 @@ def plot(
981985
xrange = [rmin, rmax]
982986
if yrange is None:
983987
yrange = [zmin, zmax]
984-
if not savefilename is None and os.path.exists(savefilename):
988+
if savefilename is not None and os.path.exists(savefilename):
985989
print("Restoring savefile " + savefilename + " ...")
986990
savefile = open(savefilename, "rb")
987991
potRz = pickle.load(savefile)
@@ -1012,7 +1016,7 @@ def plot(
10121016
potRz[:, zs > zmax] = numpy.nan
10131017
# Infinity is bad for plotting
10141018
potRz[~numpy.isfinite(potRz)] = numpy.nan
1015-
if not savefilename == None:
1019+
if savefilename is not None:
10161020
print("Writing savefile " + savefilename + " ...")
10171021
savefile = open(savefilename, "wb")
10181022
pickle.dump(potRz, savefile)
@@ -1043,6 +1047,7 @@ def plot(
10431047
justcontours=justcontours,
10441048
levels=levels,
10451049
cntrcolors=cntrcolors,
1050+
**kwargs,
10461051
)
10471052

10481053
def plotDensity(
@@ -2766,6 +2771,7 @@ def plotPotentials(
27662771
justcontours=False,
27672772
levels=None,
27682773
cntrcolors=None,
2774+
**kwargs,
27692775
):
27702776
"""
27712777
Plot a set of potentials.
@@ -2812,6 +2818,8 @@ def plotPotentials(
28122818
Save to or restore from this savefile (pickle). Default is None.
28132819
aspect : float, optional
28142820
Aspect ratio of the plot. Default is None.
2821+
**kwargs : dict, optional
2822+
Any additional keyword arguments are passed to `galpy.util.plot.dens2d`.
28152823
28162824
Returns
28172825
-------
@@ -2820,6 +2828,7 @@ def plotPotentials(
28202828
Notes
28212829
-----
28222830
- 2010-07-09 - Written by Bovy (NYU).
2831+
- 2024-07-09 - Propagate keyword arguments to `galpy.util.plot.dens2d` - Bovy (UofT)
28232832
28242833
See Also
28252834
--------
@@ -2838,7 +2847,7 @@ def plotPotentials(
28382847
xrange = [rmin, rmax]
28392848
if yrange is None:
28402849
yrange = [zmin, zmax]
2841-
if not savefilename == None and os.path.exists(savefilename):
2850+
if savefilename is not None and os.path.exists(savefilename):
28422851
print("Restoring savefile " + savefilename + " ...")
28432852
savefile = open(savefilename, "rb")
28442853
potRz = pickle.load(savefile)
@@ -2869,7 +2878,7 @@ def plotPotentials(
28692878
potRz[:, zs > zmax] = numpy.nan
28702879
# Infinity is bad for plotting
28712880
potRz[~numpy.isfinite(potRz)] = numpy.nan
2872-
if not savefilename == None:
2881+
if savefilename is not None:
28732882
print("Writing savefile " + savefilename + " ...")
28742883
savefile = open(savefilename, "wb")
28752884
pickle.dump(potRz, savefile)
@@ -2902,6 +2911,7 @@ def plotPotentials(
29022911
justcontours=justcontours,
29032912
levels=levels,
29042913
cntrcolors=cntrcolors,
2914+
**kwargs,
29052915
)
29062916

29072917

0 commit comments

Comments
 (0)