Skip to main content

An easy graph formatting tool for matplotlib

Project description

szkGraph - simple style formatter for matplotlib

This is a useful Python codes to simply modify the style of matplotlib for your presentation and academic papers. Any type of suggestions, feedbacks, and upgrades are welcome.

How to install?

Install using pip.

python -m pip install -U szkGraph

Then, import as follows.

import szkGraph.formatter

How to use?

Call formatter.prepare() to initialize the figure. Use the returned fig, ax for plotting. After plotting and modifying your figure, export the figure with formatter.finalize().

formatter.prepare(xtitle=None, ytitle=None, w=None, h=None, r=0.7, font="arial", fontsize=20)

Paramters

  • xtitle: str, optional Title of x-axis.
  • ytitle: str, optional Title of y-axis.
  • w: float or str, optional Float for specifying the width in inches, str for specifying the width relative to powerpoint slide or academic paper. Use pp1/X for one-X-th of powerpoint slide (16:9), ppX for X times of powerpoint slide (16:9), and 1col etc. for figures in academic paper.
  • h: float, optional Height in inches.
  • r: float, optional Ratio of height to width.
  • font: str, optional Fontname. It should be either arial or times.
  • fontsize: int, optional Fontsize in pt.

Returns

  • fig: matplotlib.figure
  • ax: matplotlib.axes

formatter.finalize(fig, ax, fn_figout, lims=[None, None, None, None], dpi=300, comp={}, tight=True, pad=0.2, xspace=None, yspace=None)

Paramters

  • fig: matplotlib.figure
  • ax: matplotlib.axes
  • fn_figout: str Name of the output figure file. It could also be in absolute or relative path.
  • lims: list of floats, optional Range of axis in one list as [xmin, xmax, ymin, ymax].
  • dpi: int, optional Value of dpi.
  • pil_kwargs: dict, optional Dictionary that will be directly passed to PIL.Image.Image.save.
  • tight: bool, optional Whether to use matplotlib.pyplot.tight_layout().
  • pad: float, optional Padding for matplotlib.pyplot.tight_layout().
  • xspace: float or tuple of floats Float for specifying x-tick spacing, tuple of floats for specyfing (x-tick spacing, offset). See matplotlib.ticker.MultipleLocator().
  • yspace: float or tuple of floats Float for specifying y-tick spacing, tuple of floats for specyfing (y-tick spacing, offset). See matplotlib.ticker.MultipleLocator().

Returns

  • fig: matplotlib.figure
  • ax: matplotlib.axes

License

szkGraph is available under MIT license. See the LICENSE file for more info.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

szkgraph-0.0.3.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

szkgraph-0.0.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file szkgraph-0.0.3.tar.gz.

File metadata

  • Download URL: szkgraph-0.0.3.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.9

File hashes

Hashes for szkgraph-0.0.3.tar.gz
Algorithm Hash digest
SHA256 519db2796c1e4e3bbcdbf66df0562d8db9a8a2caaba1941907cd87cb0ffc1858
MD5 2590cc08cd6eb4a1111efd4fde329f11
BLAKE2b-256 4482a34ca01ceb5aef0d9684644e41b5c2fcbdcd4fad845e1b92c77e0e50bfd8

See more details on using hashes here.

File details

Details for the file szkgraph-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: szkgraph-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.9

File hashes

Hashes for szkgraph-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a0ef43713822906d18b3b75773c3cba01043466d89fde5c495d182b1cd8dec8d
MD5 307bb04f076129df348db72fddab1221
BLAKE2b-256 e1274042c2dd78faa1d8d942aee6926dbe6362e7a28380ca6b16137f0c1082bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page