PlasmaCalcs.plotting.plotter_manager.Plotter
- class PlasmaCalcs.plotting.plotter_manager.Plotter(fname, *, f=None, who=[], kind=UNSET, kinds=UNSET, ani=UNSET, savename=None, cost=20, **kw_super)
Bases:
objectplotter which can be used by a PlotterManager.PlotterManager.KNOWN_PLOTTERS will be a dict of {str: Plotter} pairs.- fname: str
- name of the callable used to make the plot,via getattr(obj,fname)(…), where obj is a PlotterManager.
- f: None or callable
- the function to call (with PlotterManager as first arg) to make the plot.None –> get when needed, via getattr(plot_manager, plotter.fname).
- who: str or list of str
- “person” or people associated with this plotter. Arbitrary strings.E.g. to only make plots for ‘sam’ person, use PlotterManager.standard_plots(…, who=’sam’).
- kind: UNSET, str, or list of str
- “kind” or kinds associated with this plotter. Arbitrary strings.E.g. to only make plots for ‘movie’ kind, use PlotterManager.standard_plots(…, kind=’movie’).Internally, stored at Plotter.kinds (plural).
- kinds: UNSET, str, or list of str
- alias for kwarg
kind. Can providekindsorkindbut not both. - ani: UNSET or bool
- whether the plotter is for an animated plot.(commands to save/show an animated plot are different than those to save/show a static plot.)if UNSET, infer from kinds. True if kinds includes any of these (case insensitive):[‘movie’, ‘gif’, ‘ani’, ‘animation’, ‘animated’]
- savename: None or str
- default filename when doing plotter.save() for this plot.None –> use plotter.name, which is fname after removing ‘plot_’ prefix.
- cost: number
- some guess about the cost to make this plot. Default=20.when making multiple plots, go in cost order.Can also set cost thresholds and skip ones that are too expensive.
- __init__(fname, *, f=None, who=[], kind=UNSET, kinds=UNSET, ani=UNSET, savename=None, cost=20, **kw_super)
Methods
__init__(fname, *[, f, who, kind, kinds, ...])plot(plot_manager, *[, save, show, close])save([movie_obj, dst, bbox_inches])show([movie_obj])Attributes
DEFAULT_COSTMOVIE_KINDS- property name
- name of this plotter, assuming self.name looks like ‘plot_name’.
- plot(plot_manager, *, save=False, show=False, close=False, **kw_plotter)
- actually call the plotter function (plot_manager.f) associated with this Plotter.returns plotter(**kw_plotter) (unless show=True and ani=True. Then return movie_obj.ani()).Might also save, show, and/or close the plot, depending on kwargs.
- save: bool, str, or dict.
- whether to save figure after calling plotter.str –> filename=save.format(name=name, savename=savename), instead of default filename=name.dict –> pass to saver as kwargs. Use kwarg ‘dst’ to also provide filename.if plotter.ani, saver is movie_obj.ani(), else saver is plt.savefig().
- show: bool
- whether to plt.show() after making plot (and, after save).if show when ani==True, return movie_obj.ani() (so it will display in jupyter)
- close: bool
- whether to plt.show() after making plot (and, after save).if show when ani==True, return movie_obj.ani() (so it will display in jupyter)
- save(movie_obj=None, dst=None, *args_save, bbox_inches=UNSET, **kw_save)
- saves the current figure. Default behaviors appropriate if current figure is self.plot().does movie_obj.save(…) if self.ani, else plt.savefig(…).returns abspath to the created file.
- movie_obj: None or object
- dst: None or str
- file name for where to save the figure. os.makedirs(exist_ok=True) as needed.None –> use self.savenamestr –> use dst.format(name=self.name, savename=self.savename)
- bbox_inches: UNSET or any value
- if provided, pass to plt.savefig(…) but NOT movie_obj.save(…)
additional args and kwargs go to ani() or savefig().
- property savename
- name of file to save this plot to, if not provided explicitly.self.savename = None –> use self.name.self.savename = other value –> use that value.
- show(movie_obj=None, **kw_ani)
- shows the current figure. Default behaviors appropriate if current figure is self.plot().does movie_obj.ani() if self.ani, else plt.show().additional kwargs go to ani() if calling ani().