Skip to main content

An extension library for creating strip plots or dot charts w/ matplotlib + seaboard

Project description

Great things come in tiny packages. A bare minimum extension library for creating tree dot plots, strip plots or dot charts w/ matplotlib or seaborn in Python

  • Designed to work with matplotlib and seaborn in Python
  • Fully customizable

installation

pip install dotplotlib

basic usage

dotplotlib can be used to generate dot charts with minimal code. Here are some basic examples:


Example 1: Simple Dot Chart

.dotchart returns x and y lists that can be inputted straight into matplotlib or seaborn scatterplots.

from dotplotlib import dotchart
import matplotlib.pyplot as plt

data = {'size': [1, 2, 2, 3, 3, 3, 4]}

# Generate dot chart data
x, y = dotchart(data['size'])

# Plot
plt.scatter(x, y)
plt.show()

Example 2: Dot Chart with Color Mapping

Pass the data you would like to color by with the color_by= argument.

Returns an extra c list that should be passed into the c= parameter if using matplotlib or hue= if using seaborn.

from dotplotlib import dotchart
import matplotlib.pyplot as plt

data = {'size': [1, 2, 2, 3, 3, 3, 4], 'rating': [3, 2, 5, 4, 3, 6, 4]}

# Generate dot chart data with color mapping
x, y, c = dotchart(data['size'], color_by=data['rating'])

# Plot with color mapping
plt.scatter(x, y, c=c, cmap='viridis')
plt.colorbar()
plt.xlabel('Size')
plt.ylabel('Number')
plt.title('Mushroom Size Count Colored by Rating')
plt.show()

Example 3: Using make_dotchart for One-Step Plotting

Instead of just giving you x, y lists to make the plot yourself, make_dotplot() actually generates the plot.

from dotplotlib import make_dotchart

df = {'size': [1, 2, 2, 3, 3, 3, 4], 'rating': [3, 2, 5, 4, 3, 6, 7]}

# Create a dot chart with optional arguments (only the first one is mandatory)
make_dotchart(df['size'], 
                  color_by=df['rating'], # list to color by
                  reverse=False, # inverts the color mapping
                  theme='gnuplot2', # scroll down to see all themes
                  colorbar=True, 
                  xlabel='Sizes', 
                  ylabel='Size Count', 
                  title='Mushroom Sizes Colored by Rating', 
                  dot_size=40):

Example 4: Plotting in a Jupyter Notebook

If plotting inline, use the default .dotchart() to obtain x and y lists, and then adjust as necessary with one of the following:

plt.figure(figsize=(12,6))  # or
plt.figure().set_figwidth(12) # or
plt.figure().set_figheight(12)



preset themes

custom:lavender

cmap

Any cmap value supported by matplotlib (see here) will work when passed into theme='viridis'.

viridis:

gnuplot:


features

  • generate strip plots/dot charts by exploiting matplotlib/seaborn scatterplots
  • supports any cmap color profile
  • the data can be automatically sorted for better visualization, especially when using color mapping.
  • accepts both list and pandas.Series as input data.
  • set custom labels, titles, and dot sizes for your charts.
  • works with Jupyter Notebook

attribution

feature requests

  • apply to become a contributor (pls help)
  • open an issue on our GitHub repository
  • email me: justinkhlee27[at]gmail.com

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

dotplotlib-1.1.7.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

dotplotlib-1.1.7-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file dotplotlib-1.1.7.tar.gz.

File metadata

  • Download URL: dotplotlib-1.1.7.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for dotplotlib-1.1.7.tar.gz
Algorithm Hash digest
SHA256 0b8d646c2c3e3ac94bb28594cd6616ce4fbd780a25e073257ffec91a76698874
MD5 3c0ba452dc302626285b9da7adcda4d6
BLAKE2b-256 3dece8e09e9965290d9445d89e1fa082a2d9e666ce3a928ad0b9ea49267d7172

See more details on using hashes here.

File details

Details for the file dotplotlib-1.1.7-py3-none-any.whl.

File metadata

  • Download URL: dotplotlib-1.1.7-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for dotplotlib-1.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7edb74d8afdbe40ed9f41b3582cb2ab5424b0e2d829bc7357d7ba180a824c38e
MD5 6bec995bf805d634e05782d82f11e7c0
BLAKE2b-256 2271c394823bf66d9038f24133e06565b3294b49c14a6f0efcad58e2ed27a3b4

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