Context manager style of matplotlib.
Project description
contextplt
Source code repository for the contextplt package.
You can create a matplotlib figure using context manager. This package enables you to write short code and create a lot of figures in a simple manner.
Installation
pip install contextplt
Usage
You can write the matplotlib figure with context manager like this.
import contextplt as cplt
x = [1,2,3]
y = [1,2,3]
with cplt.Single(xlim=[0,5], ylim=[0,5], xlabel="xlabel", ylabel="ylabel",
title="title", figsize=(6,6), dpi=150) as p:
p.ax.plot(x,y)
The same figure without context manager becomes,
x = [1,2,3]
y = [1,2,3]
fig = plt.figure(figsize=(6,6), dpi=150)
ax = fig.add_subplot(111)
ax.plot(x,y)
ax.set_xlabel("xlabel")
ax.set_ylabel("ylabel")
ax.set_xlim([0,5])
ax.set_ylim([0,5])
plt.title("title")
The benefit of context manager is recursive use of parameters using keyword arguments.
kargs = dict(xlim=[0,5], ylim=[0,5], xlabel="xlabel", ylabel="ylabel",
title="title", figsize=(6,6), dpi=150)
with cplt.Single(**kargs) as p:
p.ax.plot(x,y)
If you want to replicate this figure options with different values, you just change inside contents of values.
Note
Dockerfile and docker-compose.yml are prepared for running example codes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for contextplt-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05712f6766e21ab238755b1bc2b01ee4938958685b56330fd0119c30f962489f |
|
MD5 | c0b13f0e9641ec49fd969319edf66972 |
|
BLAKE2b-256 | 620ee139d017fa2e834322fb1cab8c7e3dc1b97b2b4c454583635dc1c7bf94b4 |