Skip to main content

A package which formats matplotlib plots and contains some other useful functions

Project description

PyPI version

tomplotlib

tomplotlib is Tom's wrapper for matplotlib. This package will style your plots and define some useful functions, including a function for automated saving of figures labelled by date and time. The main code is found in ./tomplotlib/tpl.py

Installation

To install, run

pip install tomplotlib

Alternatively, clone this directory and then run:

python setup.py install

(install in edit mode pip install -e . if you wish the edit the code.)

Importing

Import tomplotlib into your code with: /

import tomplotlib as tpl 

set's most of the required style parameters.

Usage

  • tpl.save_figure(fig) This, in my opinion, is the most useful function. By defining a figure directory (tpl.figure_directory = "where_to_save_my/Figures/"), you can call tpl.save_figure(fig, `figureName`) on any matplotlib figure or animation object. This will timestamp the figure and save it in the figure directory (which will be made if it doesn't already exist), inside another directory which is the todays days date. By default images will be saved as .pngs and .svgs, If an animation object if passed this will be saved as '.gif' and '.mp4'.
import tomplotlib as tpl 
tpl.figure_directory = "./Figures/"
fig, ax = #some code which makes a maplotlib figure
tpl.save_figure(fig,"fig_name")
  • tpl.xy_axes(ax) Tidies the axes, leaving only x and y axes at zero.

  • tpl.set_colorscheme(colorscheme) sets the colour scheme

tpl.set_colorscheme(colorscheme=1)
fig, ax = #some code which makes a matplotlib figure

tpl.set_colorscheme(colorscheme=2)
fig, ax = #some code which makes a matplotlib figure

tpl.set_colorscheme(colorscheme='Set3')
fig, ax = #some code which makes a matplotlib figure

tpl.set_colorscheme(colorscheme=[[0.9,0.9,0.9],[0.75,0.75,0.75],[0.6,0.6,0.6],[0.45,0.45,0.45],[0.3,0.3,0.3],[0.15,0.15,0.15],[0,0,0]])
fig, ax = #some code which makes a matplotlib figure

You pass colorscheme as an int (schemes I have defined), as str (matplotlib schemes, see here) or as a list of colors (e.g. list of hexstrings). These will become C0, C1, C2...

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

tomplotlib-1.2.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

tomplotlib-1.2.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file tomplotlib-1.2.1.tar.gz.

File metadata

  • Download URL: tomplotlib-1.2.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.9

File hashes

Hashes for tomplotlib-1.2.1.tar.gz
Algorithm Hash digest
SHA256 a3b412c04108ac63a590dcdaac5b80cd6be58c0a7047bb356fbf8c304dea2374
MD5 922a4f9353b598ff278a6faa3825559d
BLAKE2b-256 10e48591c2698ea1d11b9c90d4bc492d651e59dddd4ec6bb24589593fafd09ae

See more details on using hashes here.

File details

Details for the file tomplotlib-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: tomplotlib-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.9

File hashes

Hashes for tomplotlib-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3526a0eaeaa46463095f93d819e873aa320ba351175cc73ae8a2794d72aa7834
MD5 fc04701add8a80e76add3a6ab3397f5c
BLAKE2b-256 e4b3359bf4effb666219d2f9d5e3b5c0b454ba00f47510fcfb5e668e355a053e

See more details on using hashes here.

Supported by

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