Plot multidimensional categorical data
Project description
pydiceplot
The pyDicePlot package allows you to create visualizations (dice plots) for datasets with more than two categorical variables and additional continuous variables. This tool is particularly useful for exploring complex categorical data and their relationships with continuous variables.
Requirements
This code requires python 3.
conda create --name pydiceplot python=3
conda activate pydiceplot
pip install -r requirements.txt
Installation via pip To install the package via pip, run
pip install -e .
from the base directory.
Use the dice plots in R
for using dice plots in R please refer to DicePlot
Sample Output
Figure: A sample dice plot generated using the DicePlot package.
Documentation
For full documentation and additional examples, please refer to the documentation
Usage example
import numpy as np
import pandas as pd
from pydiceplot import dice_plot
from pydiceplot.plots.backends._dice_utils import (get_diceplot_example_data,
get_example_group_colors,
get_example_cat_c_colors)
import pydiceplot
#Set the backend for pydiceplot
pydiceplot.set_backend("matplotlib")
pydiceplot.set_backend("plotly")
if __name__ == "__main__":
plot_path = "./plots"
# define colors for the example plot
# Generate and save dice plots for different numbers of pathology variables
for n in [2,3, 4, 5, 6]:
# Get the data using the utility function
# load example data
data_expanded = get_diceplot_example_data(n)
group_colors = get_example_group_colors()
cat_c_colors = get_example_cat_c_colors()
# Define pathology variables and their colors
# extract pathology variables and select proper color scale
pathology_vars = data_expanded["PathologyVariable"].unique()
current_cat_c_colors = {var: cat_c_colors[var] for var in pathology_vars}
# Create the dice plot
title = f"Dice Plot with {n} Pathology Variables"
fig = dice_plot(
data=data_expanded,
cat_a="CellType",
cat_b="Pathway",
cat_c="PathologyVariable",
group="Group", # default is set to None, it will color the boxes plain white
switch_axis=False,
title=title,
cat_c_colors=current_cat_c_colors,
group_colors=group_colors, # Include group colors
max_dice_sides=6 # Adjust if needed
)
# Display and save the figure
fig.show()
Features
- Visualize Complex Data: Easily create plots for datasets with multiple categorical variables.
- Customization: Customize plots with titles, labels, and themes.
- Integration with ggplot2: Leverages the power of
ggplot2for advanced plotting capabilities.
Contributing
We welcome contributions from the community! If you'd like to contribute:
- Fork the repository on GitHub.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a detailed description of your changes.
Contact
If you have any questions, suggestions, or issues, please open an issue on GitHub.
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydiceplot-0.0.2.tar.gz.
File metadata
- Download URL: pydiceplot-0.0.2.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0acdd89f95cdc7675e68e4414cb41b50728b37f6557dae3fdbf70a142486dd4
|
|
| MD5 |
9e85d5d03b6e805f4faaa27c2ef48745
|
|
| BLAKE2b-256 |
d8b823a95b1f0efdddaaeb5fd618e9d4af27a8315f1302b1ea788246dcd48c4f
|
File details
Details for the file pydiceplot-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pydiceplot-0.0.2-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6c1aca31d3547191697c883fb4f1ee1326ee6d1abbc357b7f6a367bad2dc73d
|
|
| MD5 |
ce2ce0c872a686ecb1cda7d1a8c3767d
|
|
| BLAKE2b-256 |
b822fe412726f368b5380e35327d7c42323c2185ea95dc4380b258a80e821414
|