Skip to main content

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 Meetings
  • SPASM : 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)

Example CHASM output

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'])

Example CHASM output

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PLASM-1.0.dev1.tar.gz (922.7 kB view details)

Uploaded Source

Built Distributions

PLASM-1.0.dev1-py3.7.egg (12.4 kB view details)

Uploaded Source

PLASM-1.0.dev1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file PLASM-1.0.dev1.tar.gz.

File metadata

  • Download URL: PLASM-1.0.dev1.tar.gz
  • Upload date:
  • Size: 922.7 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

Hashes for PLASM-1.0.dev1.tar.gz
Algorithm Hash digest
SHA256 a26e626aefcd5aae8720b1838591e8546da91a4c90674bb3cad26288247a5811
MD5 9e23514bd8d0928e83609bbbc7f4f26d
BLAKE2b-256 78d15fe394c54c101bd4d5e94daa8c8bdbb4d811f9f7c9099692d85343e33c94

See more details on using hashes here.

File details

Details for the file PLASM-1.0.dev1-py3.7.egg.

File metadata

  • Download URL: PLASM-1.0.dev1-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

Hashes for PLASM-1.0.dev1-py3.7.egg
Algorithm Hash digest
SHA256 b14cd89359b9c0f1e33ab84d502dbc90326f4a0481ef2fa3543bd371a090e1ba
MD5 09579ccf2ddec58dd245b2009b90a217
BLAKE2b-256 75020d4734dfb95afd06fe8bbaaea801d946433b7ac6f0974b305f293ff1c3c3

See more details on using hashes here.

File details

Details for the file PLASM-1.0.dev1-py3-none-any.whl.

File metadata

  • Download URL: PLASM-1.0.dev1-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

Hashes for PLASM-1.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 24b57310b7ac2026bf83912b80bfa3219358854e6f396ffa3394cc9bc858b95e
MD5 f31c6edc17a384a37c32da012903f011
BLAKE2b-256 92fa6dce14221b137408ffd47d81f3dfae6b53647b48830ab41e098b350a8e93

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