Skip to content

Commit

Permalink
updated mdap to also have hexbin plots
Browse files Browse the repository at this point in the history
  • Loading branch information
darianyang committed Dec 29, 2023
1 parent b8b6a30 commit 0913fb8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 17 deletions.
2 changes: 1 addition & 1 deletion mdap/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def main():
elif args.p_units == "raw_norm":
cbar_label = "Normalized Counts"
# if using scatter3d and no label is given, create default label
if args.plot_mode == "scatter3d" and args.cbar_label is None:
if (args.plot_mode == "scatter3d" or args.plot_mode == "hexbin3d") and args.cbar_label is None:
cbar_label = plot.Zname[0] + " i" + str(plot.Zindex)
# if there is a cbar object set label
if hasattr(plot, "cbar"):
Expand Down
68 changes: 52 additions & 16 deletions mdap/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def create_cmd_arguments():
type=str)
main.add_argument("-pm", "--plot-mode", "--plotmode", default="hist", nargs="?",
dest="plot_mode", choices=("hist", "hist_l", "contour", "contour_l",
"contour_f", "bar", "line", "scatter3d"),
"contour_f", "bar", "line", "scatter3d", "hexbin3d"),
help="The type of plot desired. "
"e.g. line for 1D, hist or contour for 2D and scatter3d for 3D.",
type=str)
Expand Down Expand Up @@ -255,6 +255,18 @@ def create_cmd_arguments():
" levels) using a gaussian filter with sigma="
"SMOOTHING_LEVEL.",
type=float)
optional.add_argument("-sci", "--scatter-iterval", default=10, nargs="?",
dest="scatter_interval",
help="Adjust to use less data for scatter plots.",
type=int)
optional.add_argument("-scs", "--scatter-s", default=1, nargs="?",
dest="scatter_s",
help="Adjust scatter plot marker size",
type=float)
optional.add_argument("-hbg", "--hexbin-grid", default=100, nargs="?",
dest="hexbin_grid",
help="Adjusts hexbin gridsize parameters.",
type=int)
optional.add_argument("-T", "--temp", default=298, nargs="?",
dest="T", help="Used with kcal/mol 'p-units'.",
type=int)
Expand All @@ -265,22 +277,21 @@ def create_cmd_arguments():
action="store_true")
optional.add_argument("-3d", "--proj3d", default=False,
dest="proj3d",
help="Make a 3d projection plot",
help="Make a 3d projection plot, works with contour or scatter plots.",
action="store_true")
optional.add_argument("--style", default="default", nargs="?",
dest="style",
help="mpl style, can use default, None, or custom. "
"Edit the wedap/styles/default.mplstyle file to "
"change default wedap plotting style options.",
type=str)
# TODO: prob cant use custom outside of list
optional.add_argument("--cmap", default="viridis", nargs="?",
dest="cmap",
help="mpl colormap name.",
type=str)
optional.add_argument("--color",
dest="color", help="Color for 1D plots and trace plots.",
widget="ColourChooser")
optional.add_argument("-4d", "--proj4d", default=False,
dest="proj4d",
help="Make a 4d projection plot, must have Cname. " +
"only works with scatter plots.",
action="store_true")
optional.add_argument("-C", "-c", "--Cname", "--cname", default=None, nargs="?",
dest="Cname",
help="Target data name for cbar of proj3d. Must use 'scatter3d' "
"for 'plot_mode'. Can be 'pcoord' or any aux dataset name "
"in your h5 file.",
type=str)
optional.add_argument("-Ci", "--Cindex", "--cindex", default=0, nargs="?", type=int,
dest="Cindex", help="Index in third dimension for >2D datasets.")

# create optional flag to not output plot to console screen
optional.add_argument("-nots", "--no-output-to-screen",
Expand Down Expand Up @@ -316,6 +327,27 @@ def create_cmd_arguments():

formatting = parser.add_argument_group("Plot Formatting Arguments")

formatting.add_argument("--style", default="default", nargs="?",
dest="style",
help="mpl style, can leave blank to use default, "
"input `None` for basic mpl settings, can use a custom "
"path to a mpl.style text file, or could use a mpl included "
"named style, e.g. `ggplot`. "
"Edit the wedap/styles/default.mplstyle file to "
"change default wedap plotting style options.",
type=str)
# TODO: prob cant use custom outside of list
formatting.add_argument("--cmap", default="viridis", nargs="?",
dest="cmap", help="mpl colormap name.", type=str)
formatting.add_argument("--color",
dest="color", help="Color for 1D plots, contour lines, and trace plots.",
widget="ColourChooser")
formatting.add_argument("--linewidth", "-lw", default=None, nargs="?",
dest="linewidth", help="Linewidth for 1D plots, contour lines, and trace plots.",
type=float)
formatting.add_argument("--linestyle", "-ls", default="-", nargs="?",
dest="linestyle", help="Linestyle for 1D plots, contour lines, and trace plots.",
type=str)
formatting.add_argument("--xlabel", dest="xlabel", type=str)
formatting.add_argument("--xlim", help="LB UB", dest="xlim", nargs=2, type=float)
formatting.add_argument("--ylabel", dest="ylabel", type=str)
Expand All @@ -324,6 +356,10 @@ def create_cmd_arguments():
formatting.add_argument("--suptitle", dest="suptitle", type=str)
formatting.add_argument("--cbar-label", dest="cbar_label", type=str)
formatting.add_argument("--grid", dest="grid", default=False, action="store_true")
formatting.add_argument("--axvline", "-vl", help="Can be a single value or a list of lines.",
dest="axvline", nargs="*", type=float)
formatting.add_argument("--axhline", "-hl", help="Can be a single value or a list of lines.",
dest="axhline", nargs="*", type=float)

# return the argument parser
return parser
Expand Down

0 comments on commit 0913fb8

Please sign in to comment.