PLot Analysis Spreads for Meetings
Project description
PLASM - PLot Analysis Spreads for Meetings
Jim Bagrow
@bagrow
https://bagrow.com
A rough-and-ready tool for preparing all combinations of log- and linear-scaled axes for a scatterplot or distribution plot (CDF, CCDF, or histogram), to save for reference.
PLASM consists of two Python functions:
CHASM
: Cdf and Histogram Analysis Spread for MeetingsSPASM
: ScatterPlot Analysis Spread for Meetings
Now when you show a scatter plot to a collaborator during a research meeting and they ask for a log-scaled x-axis, for instance, you can pull out the saved SPASM and have every combination of log- and linear-scaled axes ready to go.
Table of Contents
Usage
Add plasm
to your code:
from plasm import chasm, spasm
CHASM
Examine some distributions with chasm
:
n = 1000
X = np.random.randn(n,)
Y = np.random.randn(n,)+0.4
Z = np.random.randn(n,)+0.8
names = ["data1","data2","data3"]
chasm(X, Y, Z, names=names, show_median=True)
Now, we looked at three normal (Gaussian) distributions. A log-scaled x-axis does not make much sense for such distributions and, sure enough, those plots (semilog x and log-log) are not informative in the example. But now we have a spread we can save away just in case we are ever asked for a different axes scaling.
SPASM
Scatter plot some data with spasm
:
n = 150
X1 = np.random.randn(n,)
e = np.random.randn(n,)*0.1
Y1 = 0.3 + 1.2 * X1 + e
X2 = -1 + 2*np.random.rand(n,)
Y2 = 2*X2**2 + e
spasm(X1,Y1, X2,Y2, names=['Expr-1', 'Expr-2'])
Install
pip install plasm
Requirements
- Python 3.6+
- Numpy
- Scipy
- Matplotlib 3.x
Frequently asked questions
- Why worry about log scales?
It's very common when performing exploratory data analysis to encounter non-normal data, data that are skewed in some manner. It may be that a few extreme outliers crush the bulk of the data down into an unreadable space. Or it may be that you are looking if data follow a particular functional form, and it may be easier to discern that form with some manner of logarithmically-scaled axes.
- Can I use this for papers or presentations?
Generally, no. Or at least, that's not the intent.
The different views in a spread of plots are highly redundant. They show the same data over and over. In a meeting, internal presentation, or even during your own exploratory data analysis, seeing all these views can be very helpful to teach you the best view. Then, with that best view in mind, you can design the final plot for your paper.
You can often tell plasm is working by noticing that only a small subset of plots in a spread are useful. For instance, above we show an example using chasm
to look at three normal distributions. A log-scaled x-axis does not make much sense for such distributions and, sure enough, those plots are not informative in the example. But now we have a spread we can save away just in case we are ever asked for a different axes scaling.
- Not good for presentations, I thought this was for meetings?
By meetings, I really mean internal meetings, such as meeting with a research supervisor or some collaborators on a project. I don't mean conferences. By the time you are presenting results at a conference, you should already know which way to plot the data.
- What if I don't like the defaults?
Good point. Both CHASM and SPASM accept additional keyword arguments that get passed to the underlying plot
commands. For example, you can use SPASM to do a line plot instead of a scatter plot by passing an ls
arg:
spasm(X,Y, ls='-')
Of course, there is much more than can be done. Especially for histograms; we have only implemented a basic linear and log-binning, but there are many other ways to go about binning, including integer bins. (That there is so much choice for histogram binning, and that different binnings can change, sometimes drastically, the appearance of the distribution, is a strong argument for relying on the CDF or CCDF!)
- This is dumb. I could have easily coded it up myself.
True. Now you don't have to. Also, after coding it up, would you have come up with the killer name? :joy:
- Can I share some ribald comments using other -asm words?
Please, no.
License
BSD-3-Clause © James Bagrow
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 Distribution
Built Distributions
File details
Details for the file PLASM-1.0.dev2.tar.gz
.
File metadata
- Download URL: PLASM-1.0.dev2.tar.gz
- Upload date:
- Size: 922.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b55aa7ec94b7180ec800827dc863dbeb75609263c89651e744e39731b1869e9c |
|
MD5 | 7d2b6a6ed02892ecc20b32fc5be4d6f7 |
|
BLAKE2b-256 | 8f64109d5108b7d1aae63f33d96c037404d4f0c6539f4b457286beee2f786709 |
File details
Details for the file PLASM-1.0.dev2-py3.7.egg
.
File metadata
- Download URL: PLASM-1.0.dev2-py3.7.egg
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1accc256a98e2e6ea020152ffb1003790187adec15fcb1e36eaab60fa55f11c |
|
MD5 | f84814a34f7acd122f6ae0a9d0302d6a |
|
BLAKE2b-256 | 8f001b69d135c251e83bd991e8f6b3671fb793764d8917e5e872af6d6d5fca53 |
File details
Details for the file PLASM-1.0.dev2-py3-none-any.whl
.
File metadata
- Download URL: PLASM-1.0.dev2-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 272f09f58b3b570901c76f7cd1136faaf555722dae5e1237241a8b70f4c668b4 |
|
MD5 | ddfd8b1906e9dac73d83b96860b234d5 |
|
BLAKE2b-256 | 5c7e5c846442236fa9642d8ebbf36095f053e22a51ba14db88dbc57749241e8c |