pysymlog -- Symmetric (signed) logarithm scale for your python plots
version 1.0.1
API documentation: https://pysymlog.readthedocs.io
Examples: https://github.com/pjcigan/pysymlog/examples/tutorial_mpl.ipynb
This package provides some utilities for binning, normalizing colors, wrangling tick marks, and more, in symmetric logarithm space. That is, for numbers spanning positive and negative values, working in log scale with a transition through zero, down to some threshold. Utilities are given for calculating arrays and histograms, plotting in matplotlib, and plotting in plotly. This can be quite useful for representing data that span many scales like standard log-space, but that include values of zero (that might be returned by physical measurement) or even negative values (for example offsets from some reference, or things like temperatures).
It should be noted that of course matplotlib now has the 'symlog' scale (with linear values near zero, below some threshold) as well as asinh scale (also with smooth transition through zero), providing quite similar matplotlib plotting functionality for setting axis scales and colormap normalization. Beyond simply providing one more alternative, this package provides convenient functions for creating 1D and 2D histograms and symmetric log bins, generating logspace-like arrays through zero and managing matplotlib major and minor ticks in symlog space, as well as bringing symmetric log scaling functionality to plotly.
Sharing/Customization: Please, play around! (MIT License)
If you find this useful for your work, giving this package a nod in your acknowledgments would be greatly appreciated.
Dependencies
-
numpy
-
matplotlib (optional)
-
plotly (optional)
- Tested in python 3.7, 3.10
Installation
Install with pip
pip install pysymlog
Usage
Example basic usage, without importing any plot packages:
import pysymlog as psl
## Making a histogram in symmetric log space
counts, bin_edges = psl.symlogbin_histogram(data, Nbins=50, shift=1, base=10)
## Making a 2D histogram in symmetric log space
counts, bins_x, bins_y = psl.symlogbin_histogram2d(xdata, ydata, 50, limits=['auto','auto'], shift=1, base=10)
Example basic usage with matplotlib:
import pysymlog
## Loading matplotlib utilities and registering 'symmetriclog' scale
pysymlog.register_mpl()
## Making a plot in symmetriclog scale
from matplotlib import pyplot as plt
ax1=plt.subplot(111)
plt.plot(xdata,ydata);
plt.yscale(SymmetricLogarithmScale(ax1,shift=0.01))
# or
plt.yscale('symmetriclog',shift=0.01)
plt.show()
Example basic usage with plotly:
import pysymlog
## Loading the plotly utilities
pysymlog.register_plotly()
## Making a scatter plot with plotly.graph_objects, log scale on y axis
fig = go.Figure()
psl.go_scatter_symlog(fig, xdata, ydata, xy='y')
fig.show()
## Making a line plot with plotly.express, log scale on y axis
fig = psl.px_line_symlog(xdata, ydata, xy='y')
fig.show()
API documentation can be found at https://pysymlog.readthedocs.io
See the examples jupyter notebook for much more detail and example usage.
Example gallery:
Metadata
Release files for pysymlog 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pysymlog-1.0.1.tar.gz | 18.9 kB | Without provenance | Details for pysymlog-1.0.1.tar.gz |
Release files / pysymlog-1.0.1.tar.gz
| Download URL | pysymlog-1.0.1.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fae29e442b286dc71810c4a76c12c876afe71a1db0f7f2da477a4b0bf33d8d79
|
|
BLAKE2b-256 checksum How to use checksums |
80a7deaca62cb2d7c445b76cde40b13305d079c0c52552c93e4e3e2c98798dda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Security for pysymlog 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.