No project description provided
Project description
subplots_from_axsize
This package provides a single function, subplots_from_axsize()
, which is based on matplotlib's subplots()
and adjust_subplots()
functions, but:
figsize
is replaced byaxsize
left
,bottom
,right
,top
use inches instead of fractionswspace
,hspace
use inches instead of fractionsaxsize
,wspace
,hspace
can take lists as arguments (see example #2 below)
rationale
Specifying sizes directly makes it easier to achieve consistent ax sizes across figures. Suppose you're plotting various time series data and you would like consistent inches / week on your x axis. Or you carefully crafted your figures but suddenly you need a little extra space for you labels. Or you would want to move the axes a little bit apart and not rescale everything else in the whole world simultaneously.
getting started
The package is available on PyPi.
example #1
import matplotlib.pyplot as plt
from subplots_from_axsize import subplots_from_axsize
fig, ax = subplots_from_axsize(
axsize=(4, 3),
left=0.9, bottom=0.5, top=0.3, right=0.2,
)
ax.set_xlabel('x label')
ax.set_ylabel('y label\nbut much\nmuch longer')
ax.set_title('important!')
fig.patch.set_facecolor('#ffbbff')
Since the default dpi in matplotlib is 100, the axis is exactly 400 by 300 pixels. The left margin, for example, is 0.9 × 100 = 90 pixels. Changing the margins does not change the axis size (you have my promise).
example #2
Additionally, subplots_from_axsize
makes it easy to create multiple axes.
import matplotlib.pyplot as plt
from subplots_from_axsize import subplots_from_axsize
fig, axs = subplots_from_axsize(
axsize=([1, 3], 1),
hspace=[0.5, 1.0],
left=0.4, bottom=0.3,
)
fig.patch.set_facecolor('#ffbbff')
The number of columns (or rows) is inferred automatically based on three arguments: nrows
(if given), length of axsize[0]
(if it is a list), length of wspace
+ 1 (if it is a list). If none of the conditions is met, the default is 1. If they disagree you get an error (xor create an Issue).
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
Built Distribution
File details
Details for the file subplots_from_axsize-0.1.9.tar.gz
.
File metadata
- Download URL: subplots_from_axsize-0.1.9.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.5 Linux/6.5.7-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2e1cd94fba7c604957bd50e11cde5313e0cb7493d2108fe96b095a15ac535d8 |
|
MD5 | de447733604d1e7ae38894ccda93e61a |
|
BLAKE2b-256 | fb8d43c4622ead1ea8370bfcf9cc54546aa25df7ca595e18bf3d204dc7705503 |
File details
Details for the file subplots_from_axsize-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: subplots_from_axsize-0.1.9-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.5 Linux/6.5.7-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6771d0b13ddfe0404a1c281e986bce2c0eb1a0e3b672c9ac277fac6bae8765c |
|
MD5 | 8be140f51515506d55f892b158671204 |
|
BLAKE2b-256 | 01cb0fb8167e34bae4c2e5b0b819e7f0f4b5a37de31179bc0a88c75d738b09a4 |