Data visualization toolbox.
Project description
Welcome to the dataoutsider visualization toolbox!
Featuring:
- Multi-Chord Diagram
- Pie-Tree Chart (or Pie-Map Chart)
Multi-Chord Diagram
Have too many sets for a Venn Diagram?
- Prepare groups a. Select 2 fields that identify 1. a group (ex: sports event) and 2. an entity (ex: athlete) to identify the many-to-many relationships (ex: many athletes to many events) or b. Pre-group data and provide each unique group combination (ex: athletes that competed in only the [100 meter] vs those that competed in only the [100 meter & 200 meter], etc.) and associated entity count (ex: # of athletes per group)
- Configure the parent-group order
- The multi-chord diagram will create bonds between many-to-many relationships, sized by the entity count per each unique group combination (ex: 10 athletes competed in only the [50 meter, 100 meter, & meter], 23 athletes competed in only the [100 meter], etc.)
Assumes 1 row = 1 unit for 1. a.
Example 1 (1. a.):
from dataoutsider import multi_chord as mc
df = mc.load_olympics_df()
df = df.loc[(df['Year'] >= 2014) & (df['Sex'] == 'F') & (df['Sport'] == 'Speed Skating')]
outer = 'Event'
inner = 'ID'
lookup = mc.multi_chord_get_alias(df, outer, inner)
print(lookup)
df_mc = mc.multi_chord_alias(df, outer, inner, percent = 75.)
df_mc_venn = mc.multi_chord_venn(df_mc)
mc.multi_chord_plot(df_mc, level = 4, transparency = 0.5)
Example 2 (1. b.):
from dataoutsider import multi_chord as mc
import pandas as pd
data = [['a', 25.5], ['a,b', 15], ['a,c', 14.4], ['a,c,d', 5], ['c,d', 13], ['d', 14], ['c,b', 10], ['b', 7]]
df = pd.DataFrame(data, columns = ['group', 'value'])
df_mc = mc.multi_chord_on_groups_alias(df, percent=33.)
df_mc_venn = mc.multi_chord_venn(df_mc)
mc.multi_chord_plot(df_mc, level = 3, transparency = 0.5)
Example 3 (1. a.):
from dataoutsider import multi_chord as mc
import pandas as pd
data = [['5', 'a'], ['5', 'b'], ['5', 'd'], ['2', 'b'], ['2', 'c'], ['3', 'b'], ['3', 'd'], ['4', 'c']]
df = pd.DataFrame(data, columns = ['inner', 'outer'])
lookup = mc.multi_chord_get_alias(df, 'outer', 'inner')
print(lookup) # use outer_ID (alias) to set manual order
df_mc = mc.multi_chord_alias(df, outer='outer', inner='inner', order='1,3,2,4', percent=33.) #, order = 'b,c,d,a'
mc.multi_chord_plot(df_mc, level = 3, transparency = 0.5)
Example 4 (1. b. version of Example 3):
from dataoutsider import multi_chord as mc
import pandas as pd
data = [['a,b,d', 1], ['b,c', 1], ['b,d', 1], ['c', 1]]
df = pd.DataFrame(data, columns = ['group', 'value'])
df_mc = mc.multi_chord_on_groups_alias(df, order = 'b,c,d,a', percent=33.)
mc.multi_chord_plot(df_mc, level = 3, transparency = 0.5)
Functions:
multi_chord_alias(df, outer, inner, percent=100., order=None, buffer = 1., elements_offset = 0.04, elements_height = 0.04, group_offset = 0., group_height = 0.04)
multi_chord_get_alias(df, outer, inner)
multi_chord_on_groups_alias(df_chord, percent=100., order=None, buffer = 1., elements_offset = 0.04, elements_height = 0.04, group_offset = 0., group_height = 0.04)
multi_chord_venn(df_mc)
multi_chord_plot(df_mc, level = None, transparency = 0.5)
- multi_chord_alias: Multi-Chord Diagram generator that encodes the supplied groups with an alias
- multi_chord_get_alias: retreive the alias for the supplied groups (can use to create a manual ordering)
- multi_chord_on_groups_alias: Multi-Chord Diagram generator based on pre-defined groupings
- multi_chord_venn: output for creating an Upset plot
- multi_chord_plot: generate a plot using Matplotlib
Parameters:
Parameter | Values | Description |
---|---|---|
df | (DataFrame) | Pandas DataFrame |
outer | (string) | Column name of group |
inner | (string) | Column name of group entity |
percent | (float: 0-100) | Percent of full circle to draw within |
order | (csv string) | Group order |
buffer | (float) | Radial distance between groups |
elements_offset | (float) | Distance offset of element legend for entities |
elements_height | (float) | Height of element legend for entities |
group_offset | (float) | Distance offset of group legend |
group_height | (float) | Height of group legend |
df_mc | (DataFrame) | Pandas DataFrame of multi-chord results |
level | (int) | Bold chords by count of groups in chord (optional) |
transparency | (float: 0-1) | Add color transparency (optional) |
Pie-Tree Chart
Need to display hierarchical density as pie-shaped areas?
- Select [1 to n] categorical columns from a dataframe to group by
- Configure the chart ordering and hierarchy orientation
- The pie-tree chart will create a hierarchical set of areas sized by the number of rows in each group at each level
Assumes 1 row = 1 unit
Example:
from dataoutsider import pie_tree as pt
df = pt.load_aircraft_df()
levels = ['Registrant', 'Aircraft', 'Engine', 'seats_bin']
inner_radius = 0.5
outer_radius = 2.0
starting_angle = 0.0
ending_angle = 360.0
point_resolution = 200
pie_tree_df = pt.pie_tree_calc(
df, levels,
inner_radius,
outer_radius,
starting_angle,
ending_angle,
point_resolution)
pt.pie_tree_plot(pie_tree_df, 4)
Functions:
def pie_tree_calc(df, groupers, r1, r2, start_angle, end_angle, points, default_sort = False, default_sort_override = True, default_sort_override_reversed = False, all_vertical = False)
pie_tree_plot(pie_tree_df, level = 1, transparency = 0.5, line_level = 0)
- def pie_tree_calc: Pie-Tree (Pie-Map) Chart generator
- multi_chord_plot: generate a plot using Matplotlib
Parameters:
Parameter | Values | Description |
---|---|---|
df | (DataFrame) | Pandas DataFrame |
groupers | list of (string) | Columns names in df |
r1 | (float) | Innder radius |
r2 | (float) | Outer radius (> inner radius) |
start_angle | (float) | Angle to start drawing |
end_angle | (float) | Angle to end drawing |
points | (int) | Resolution for curve drawing |
default_sort | True/False | Default: False, True: pandas sort, False: data sort |
default_sort_override | True/False | Default: True, True: overrides default_sort |
default_sort_override_reversed | True/False | Default: False, sort areas True: desc, False: asc |
all_vertical | True/False | Default: False, True: break levels vertically, False: alternate |
level | (int) | Hierarchy level to plot (optional) |
transparency | (float: 0-1) | Add color transparency (optional) |
line_level | (int) | Hierarchy level to bold (optional) |
Variations:
Tableau users
Output:
- Polygon chart: Columns: [x], Rows: [y], Path: [path], Detail: varies by algorithm, use grouping fields as needed (see examples below)
Examples:
- Multi-Chord Diagram: Sink or Swim
- Pie Tree Chart: Takeoff
Check back soon for updates!
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
dataoutsider-1.1.0.tar.gz
(12.6 kB
view details)
Built Distribution
File details
Details for the file dataoutsider-1.1.0.tar.gz
.
File metadata
- Download URL: dataoutsider-1.1.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b51b8ae3880257132e33899b370183623b34592f1184928b7c808b58b2068c3a |
|
MD5 | b7947b7815b5dd6efd7e2e4a8fda2285 |
|
BLAKE2b-256 | 922ebf959535d4116df8c6d338a18f9500e8da4490e611613deee661364cf755 |
File details
Details for the file dataoutsider-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: dataoutsider-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2de900d87e2a12dd4f481e84ad4906b8488a63f0db467588a460fdafce1bd34e |
|
MD5 | cc6e4b6e94f207705cbe3877d98d2c99 |
|
BLAKE2b-256 | d09095783f57327de572fd0ac1fb0517b9a6d794803d78faaae383b2414e85bc |