coalispr.resources.plot_utilities¶
Attributes¶
Functions¶
|
Returns text annotation to plot. |
|
Construct a 'broken' xaxis, i.e. with a gap to fit most of the data. |
|
Create label with first word capitalized. |
|
Adapt toolbar to keep sensible controls. |
|
Returns common values for matplotlib rc parameters. |
|
Create broken x-axis with reduced number of tick-labels. |
|
Set common sns settings |
|
Text used for including figure titles or not. |
|
Save a figure with name at given location. |
|
Returns common values for axes of a matplotlib figure. |
Module Contents¶
- coalispr.resources.plot_utilities.logger¶
- coalispr.resources.plot_utilities.anchored_text(text)¶
Returns text annotation to plot.
- coalispr.resources.plot_utilities.break_xaxis(ax, ind, r=1)¶
Construct a ‘broken’ xaxis, i.e. with a gap to fit most of the data.
Notes
This is done by restricting the numebres and adding a text-annotation that mimicks the dividing lines of a ‘broken-axis’.
- Parameters:
ax (AxesSubplot) – Object to manipulate xaxis for
ind (int) – Coordinate halfway omitted interval to place ‘/ /’ text annotation.
r (int) – Flag to indicate amount of margin the annotation needs to be offset by.
- coalispr.resources.plot_utilities.capit_label(label)¶
Create label with first word capitalized.
- coalispr.resources.plot_utilities.edit_toolbar(fig, onlySave=False)¶
Adapt toolbar to keep sensible controls.
Notes
https://docs.python.org/3/library/warnings.html#overriding-the-default-filter f”https://matplotlib.org/{matplotlib.__version__}/_modules/matplotlib/backend_managers.html” f”https://matplotlib.org/{matplotlib.__version__}/api/backend_tools_api.html” f”https://matplotlib.org/{matplotlib.__version__}/api/backend_bases_api.html?highlight=toolitems#matplotlib.backend_bases.NavigationToolbar2.toolitems”
Adapt tool items shown in GUI menu bar; omit some disruptive options.
The resulting tuple of 4-placed tuples will become:
toolitems = ( ('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous view', 'back', 'back'), ('Forward', 'Forward to next view', 'forward', 'forward'), (None, None, None, None), ('Pan', 'Left button pans, Right button zooms x/y fixes axis, CTRL fixes aspect', 'move', 'pan'), ('Zoom', 'Zoom to rectangle x/y fixes axis, CTRL fixes aspect', 'zoom_to_rect', 'zoom'), ('Subplots', 'Configure subplots', 'subplots','configure_subplots'), (None, None, None, None), ('Save', 'Save the figure', 'filesave', 'save_figure'), )
- Parameters:
fig (matplotlib.figure.Figure) – Figure for which the GUI gets shown.
onlySave (bool) – Keep only the ‘save’ button in the toolbar (the rest won’t be useful).
- Returns:
toolitems, a tuple of 4-placed tuples (see above)
- Return type:
tuple
- coalispr.resources.plot_utilities.get_context(font_size=CSFONTSZ)¶
Returns common values for matplotlib rc parameters.
- coalispr.resources.plot_utilities.less_xlabels(ax, axeslist, r=1)¶
Create broken x-axis with reduced number of tick-labels.
- Parameters:
ax (AxesSubplot) – Object to draw labels for
axeslist (list) – Objects to draw broken axis for
ok (bool) – Create ‘broken’ sign?
r (int) – Factor to reduce number of labels.
- coalispr.resources.plot_utilities.init_sns()¶
Set common sns settings
- coalispr.resources.plot_utilities.no_titles(text, notitles)¶
Text used for including figure titles or not.
- coalispr.resources.plot_utilities.save_output_as(fnam, savdir, savepath=FIGDIR)¶
Save a figure with name at given location.
- Parameters:
fnam (str) – Name of figure to save.
savdir (str) – Sub-folder for similar kinds of figures.
savepath (Path) – Path to folder with figures, FIGDIR, in PRGNAM workfolder.
- coalispr.resources.plot_utilities.set_axes(ax, format_ax=None, log2_ax=None)¶
Returns common values for axes of a matplotlib figure.
- Parameters:
ax (matplotlib.axes) – Axes to adapt.
format_ax (str) – Name of axis to format, “x” or “y”.
log2_ax (str) – Name of axis to change to log2 scale, “x” (or “y”).