Easily create graphs using custom styling
Project description
Cmotions Dataviz
cmo_dataviz is a Python library created by The Analytics Lab, which is powered by Cmotions. This library makes it easy for us to create graphs in our prefered styling and using Cmotions colors by default. Nothing fancy, but very useful for our consultants. Mostly since this package is used in other packages, which makes our workflow simpler and more efficient.
Since we love to share what we do, why not also do that with our packages, that is why we've decided to make (almost) all of our packages open source, this way we hope to give back to the community that brings us so much. Enjoy!
Installation
Install cmo_dataviz using pip
pip install cmo-dataviz
If you want to be able to use the tutorial notebook or the code below, you also need to install pydataset using pip
pip install pydataset
Usage
from pydataset import data
import cmo_dataviz as dv
import matplotlib.pyplot as plt
import pandas as pd
# import your own stylesheet if relevant
dv.import_style('mydocuments/mystylesheet.mplstyle')
df = data("iris")
df_summary = df.groupby('Species').agg({'Sepal.Length': 'mean','Sepal.Width': 'sum', 'Petal.Length': 'mean', 'Petal.Width': 'sum'}).reset_index()
# create a single plot with default settings for size and so on
dv.create_horizontal_barplot(data=df_summary, x_var='Sepal.Width', y_var='Species', x_label="", title="", ax=None)
plt.show()
# adjust the size (or other settings) of the plot
fig, ax = plt.subplots(figsize=(5,5))
dv.create_horizontal_barplot(data=df_summary, x_var='Sepal.Width', y_var='Species', x_label="", title="", ax=ax)
plt.show()
# combine multiple graphs in a single plot
fig, ax = plt.subplots(2, 2, figsize=(10,7))
dv.create_histogram(data=df, var="Petal.Width", color_by="Species", bins=10, max_categories=50, ax=ax[0,0], title="our histogram")
dv.create_scatterplot(data=df, x_var="Sepal.Width", y_var="Sepal.Length", title="our scatterplot", ax=ax[0,1])
dv.create_boxplot(data=df, x_var="Petal.Length", y_var="Species", color_by=None, ax=ax[1,0], title="our boxplot")
dv.create_swarmplot(data=df, x_var="Sepal.Width", y_var=None, color_by= "Species", ax=ax[1,1])
plt.show()
# create example data for a network graph
networkdata = {
'source': ['A', 'B', 'C', 'D', 'E', 'B', 'C', 'C', 'C'],
'target': ['B', 'C', 'D', 'E', 'A', 'D', 'E', 'D', 'D'],
'label': ['relation1', 'relation2', 'relation3', 'relation4', 'relation5', 'relation6', 'relation7', 'relation8', 'relation9']
}
networkdata = pd.DataFrame(networkdata)
# create a network graph
dv.create_network_graph(
data=networkdata,
node_1='source',
node_2='target',
edge_label='label',
title="my network graph",
figsize=(5, 5),
ax=None,
seed=1502)
plt.show()
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.
License
GNU General Public License v3.0
Contributors
Jeanine Schoonemann
Contact us
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
Built Distribution
File details
Details for the file cmo_dataviz-0.1.2.tar.gz
.
File metadata
- Download URL: cmo_dataviz-0.1.2.tar.gz
- Upload date:
- Size: 108.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13d771e50324164a0893b85bc3b8cffa7a09af38dca477ce69f3c506ad5a572e |
|
MD5 | 2f7c14664b85f0a7561d1efc9f4f9c66 |
|
BLAKE2b-256 | 95b4f74eedd687653bacf8d9c2dd00b440883a1436a85bb1219bd93769dcac81 |
File details
Details for the file cmo_dataviz-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: cmo_dataviz-0.1.2-py3-none-any.whl
- Upload date:
- Size: 105.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 632594e7a0d20cc59a0b92b2719fc34c375023e63ddec06d010b7191f07257aa |
|
MD5 | 2e6f127faddcb2fcc7ea7111643938ca |
|
BLAKE2b-256 | 47382eb61228c7b4777eabe31ca52d31d41dafdcd5c384d07aec1d81b4f1172e |