A few conveniences for working with matplotlib.
*Latest release 20241122*:
* FigureSize: fix field factories.
* print_figure: wire a .png extension for the temp image.
## <a name="axes"></a>`axes(figure=None, ax=None, **fig_kw) -> matplotlib.axes._axes.Axes`
Return a set of `Axes`.
Parameters:
* `figure`: optional `Figure` from which to obtain the `Axes`
or an `(x,y)` figure size or an `(x,y,dpi)` figure size
* `ax`: optional `Axes` or axes index
If `ax` is already an `Axes` it is returned unchanged.
Otherwise `ax` should be the index of a set of axes,
default `0`.
If `figure` is a `Figure`, `ax` is used to select one of its
sets of axes.
Otherwise a `Figure` is created and a set of axes is selected.
The default figure size comes from the `FigureSize` defaults.
The `figure` positional parameter may be supplied
as a 2-tuple `(fig_dx,fig_dy)` to override the default size
or as a 3-tuple `(fig_dx,fig_dy,dpi)` to override the default size and dpi,
or as a `FigureSze`.
## <a name="FigureSize"></a>Class `FigureSize`
Specifications for a `Figure`'s dimensions.
*`FigureSize.Figure(self, **kw)`*:
Return a new `Figure` of this size.
It will have no subplots.
## <a name="print_figure"></a>`print_figure(figure_or_ax, imgformat=None, file=None)`
Print `figure_or_ax` to a file.
Parameters:
* `figure_or_ax`: a `matplotlib.figure.Figure` or an object
with a `.figure` attribute such as a set of `Axes`
* `imgformat`: optional output format; if omitted use `'sixel'`
if `file` is a terminal, otherwise `'png'`
* `file`: the output file, default `sys.stdout`
## <a name="remove_decorations"></a>`remove_decorations(figure_or_ax: Union[matplotlib.figure.Figure, matplotlib.axes._axes.Axes])`
Remove all decorations from a `Figure` or `Axes` instance,
intended for making bare plots such as a tile in GUI.
Presently this removes:
- axes markings and legend from each axis
- the padding from all the figure subplots
## <a name="save_figure"></a>`save_figure(figure_or_ax, imgpath: str, force=False)`
Save a `Figure` to the file `imgpath`.
Parameters:
* `figure_or_ax`: a `matplotlib.figure.Figure` or an object
with a `.figure` attribute such as a set of `Axes`
* `imgpath`: the filesystem path to which to save the image
* `force`: optional flag, default `False`: if true the `imgpath`
will be written to even if it exists
## <a name="saved_figure"></a>`saved_figure(figure_or_ax, dir=None, ext=None)`
Context manager to save a `Figure` to a file and yield the file path.
The file is removed on exit from the context.
Parameters:
* `figure_or_ax`: a `matplotlib.figure.Figure` or an object
with a `.figure` attribute such as a set of `Axes`
* `dir`: passed to `tempfile.TemporaryDirectory`
* `ext`: optional file extension, default `'png'`
# Release Log
*Release 20241122*:
* FigureSize: fix field factories.
* print_figure: wire a .png extension for the temp image.
*Release 20230407*:
FigureSize: get defaults via $FIGURE_SIZE_DX, $FIGURE_SIZE_DY and $FIGURE_SIZE_DPI envvars.
*Release 20220918*:
* New FigureSize class.
* axes(): accept a FigureSize for figure.
*Release 20220805*:
Initial PyPI release.
Raw data
{
"_id": null,
"home_page": null,
"name": "cs-mplutils",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python3",
"author": null,
"author_email": "Cameron Simpson <cs@cskk.id.au>",
"download_url": "https://files.pythonhosted.org/packages/c8/f4/2cab3ef6ac14ce0f3fb189eb4d87ee2028262cac75b6684cd227f32eb92a/cs_mplutils-20241122.tar.gz",
"platform": null,
"description": "A few conveniences for working with matplotlib.\n\n*Latest release 20241122*:\n* FigureSize: fix field factories.\n* print_figure: wire a .png extension for the temp image.\n\n## <a name=\"axes\"></a>`axes(figure=None, ax=None, **fig_kw) -> matplotlib.axes._axes.Axes`\n\nReturn a set of `Axes`.\n\nParameters:\n* `figure`: optional `Figure` from which to obtain the `Axes`\n or an `(x,y)` figure size or an `(x,y,dpi)` figure size\n* `ax`: optional `Axes` or axes index\n\nIf `ax` is already an `Axes` it is returned unchanged.\nOtherwise `ax` should be the index of a set of axes,\ndefault `0`.\n\nIf `figure` is a `Figure`, `ax` is used to select one of its\nsets of axes.\n\nOtherwise a `Figure` is created and a set of axes is selected.\nThe default figure size comes from the `FigureSize` defaults.\n\nThe `figure` positional parameter may be supplied\nas a 2-tuple `(fig_dx,fig_dy)` to override the default size\nor as a 3-tuple `(fig_dx,fig_dy,dpi)` to override the default size and dpi,\nor as a `FigureSze`.\n\n## <a name=\"FigureSize\"></a>Class `FigureSize`\n\nSpecifications for a `Figure`'s dimensions.\n\n*`FigureSize.Figure(self, **kw)`*:\nReturn a new `Figure` of this size.\nIt will have no subplots.\n\n## <a name=\"print_figure\"></a>`print_figure(figure_or_ax, imgformat=None, file=None)`\n\nPrint `figure_or_ax` to a file.\n\nParameters:\n* `figure_or_ax`: a `matplotlib.figure.Figure` or an object\n with a `.figure` attribute such as a set of `Axes`\n* `imgformat`: optional output format; if omitted use `'sixel'`\n if `file` is a terminal, otherwise `'png'`\n* `file`: the output file, default `sys.stdout`\n\n## <a name=\"remove_decorations\"></a>`remove_decorations(figure_or_ax: Union[matplotlib.figure.Figure, matplotlib.axes._axes.Axes])`\n\nRemove all decorations from a `Figure` or `Axes` instance,\nintended for making bare plots such as a tile in GUI.\n\nPresently this removes:\n- axes markings and legend from each axis\n- the padding from all the figure subplots\n\n## <a name=\"save_figure\"></a>`save_figure(figure_or_ax, imgpath: str, force=False)`\n\nSave a `Figure` to the file `imgpath`.\n\nParameters:\n* `figure_or_ax`: a `matplotlib.figure.Figure` or an object\n with a `.figure` attribute such as a set of `Axes`\n* `imgpath`: the filesystem path to which to save the image\n* `force`: optional flag, default `False`: if true the `imgpath`\n will be written to even if it exists\n\n## <a name=\"saved_figure\"></a>`saved_figure(figure_or_ax, dir=None, ext=None)`\n\nContext manager to save a `Figure` to a file and yield the file path.\nThe file is removed on exit from the context.\n\nParameters:\n* `figure_or_ax`: a `matplotlib.figure.Figure` or an object\n with a `.figure` attribute such as a set of `Axes`\n* `dir`: passed to `tempfile.TemporaryDirectory`\n* `ext`: optional file extension, default `'png'`\n\n# Release Log\n\n\n\n*Release 20241122*:\n* FigureSize: fix field factories.\n* print_figure: wire a .png extension for the temp image.\n\n*Release 20230407*:\nFigureSize: get defaults via $FIGURE_SIZE_DX, $FIGURE_SIZE_DY and $FIGURE_SIZE_DPI envvars.\n\n*Release 20220918*:\n* New FigureSize class.\n* axes(): accept a FigureSize for figure.\n\n*Release 20220805*:\nInitial PyPI release.\n",
"bugtrack_url": null,
"license": "GNU General Public License v3 or later (GPLv3+)",
"summary": "A few conveniences for working with matplotlib.",
"version": "20241122",
"project_urls": {
"MonoRepo Commits": "https://bitbucket.org/cameron_simpson/css/commits/branch/main",
"Monorepo Git Mirror": "https://github.com/cameron-simpson/css",
"Monorepo Hg/Mercurial Mirror": "https://hg.sr.ht/~cameron-simpson/css",
"Source": "https://github.com/cameron-simpson/css/blob/main/lib/python/cs/mplutils.py"
},
"split_keywords": [
"python3"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1603860dadce69533f476b95ea61ffece047d072576407ed490b7cb78002abfb",
"md5": "ab3c851eee511e2e6a60a7e4cd9e27fa",
"sha256": "04632a3d02de36a939f4f1a8ca2b11ce4d99d9ad134d0f380b614484258e5dcf"
},
"downloads": -1,
"filename": "cs_mplutils-20241122-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ab3c851eee511e2e6a60a7e4cd9e27fa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5268,
"upload_time": "2024-11-22T09:05:18",
"upload_time_iso_8601": "2024-11-22T09:05:18.752757Z",
"url": "https://files.pythonhosted.org/packages/16/03/860dadce69533f476b95ea61ffece047d072576407ed490b7cb78002abfb/cs_mplutils-20241122-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c8f42cab3ef6ac14ce0f3fb189eb4d87ee2028262cac75b6684cd227f32eb92a",
"md5": "ce9f02276603efc4ff6e778b169be24b",
"sha256": "5d140572a1c1283afdd5c8b8f85aa01e3e3c6866e4f279ebfd26b6a5aafd3af7"
},
"downloads": -1,
"filename": "cs_mplutils-20241122.tar.gz",
"has_sig": false,
"md5_digest": "ce9f02276603efc4ff6e778b169be24b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4902,
"upload_time": "2024-11-22T09:05:21",
"upload_time_iso_8601": "2024-11-22T09:05:21.886612Z",
"url": "https://files.pythonhosted.org/packages/c8/f4/2cab3ef6ac14ce0f3fb189eb4d87ee2028262cac75b6684cd227f32eb92a/cs_mplutils-20241122.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-22 09:05:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cameron-simpson",
"github_project": "css",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "cs-mplutils"
}