Pybeeswarm
Beeswarm plots for python
Install / Use
/learn @mgymrek/PybeeswarmREADME
pybeeswarm
Beeswarm plots for python. Inspired by R beeswarm plots
Install
The easiest way to install pybeeswarm is using pip:
sudo pip install pybeeswarm
To install the latest version on github, simply do:
git clone https://github.com/mgymrek/pybeeswarm.git
cd pybeeswarm
sudo python setup.py install
To test that it worked, open up python and check that import beeswarm doesn't give you any errors.
Requirements
This package requires:
- matplotlib
- numpy
- pandas
Basic usage
There is only one function, beeswarm:
from beeswarm import *
help(beeswarm)
Help on function beeswarm in module beeswarm.beeswarm:
beeswarm(values, positions=None, method='swarm', ax=None, s=20, col='black', xlim=None, ylim=None, labels=None)
beeswarm(values, positions=None, method="swarm",
ax=None, s=20, col="black", xlim=None, ylim=None,
labels=None)
Inputs:
* values: an array of a sequence of vectors
* positions: sets the horizontal positions of the swarms.
Ticks and labels are set to match the positions.
If none, set positions to range(len(values))
Default: None
* method: how to jitter the x coordinates. Choose from
"swarm", "hex", "center", "square"
Default: swarm
* ax: use this axis for plotting. If none supplied, make a new one
Default: None
* s: size of points in points^2 (assuming 72 points/inch).
Defautt: 20
* col: color of points. Can be:
- a single string: color all points that color
- a vector of strings length len(values): gives color for each group
- a vector of strings length sum([len(values[i]) for i in range(len(values))])
gives color for each point
- a vector of strings any other length: cycle through the list of colors.
(really pretty if not useful)
Default: "black"
* xlim: tuple giving (xmin, xmax). If not specified, either get
from the supplied ax or recalculate
* ylim: tuple giving (ymin, ymax). If not specified, eiterh get
from the supplied as or recalculate
* labels: list of labels for each group.
Default: range(len(values))
Returns:
* bs: pandas.DataFrame with columns: xorig, yorig, xnew, ynew, color
* ax: the axis used for plotting
Here's a small example:
from beeswarm import *
import matplotlib.pyplot as plt
import numpy as np
d1 = np.random.uniform(low=-3, high=3, size=100)
d2 = np.random.normal(size=100)
bs, ax = beeswarm([d1,d2], method="swarm", labels=["sample 1", "sample 2"], col=["blue","red"])
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
