Barchart

Barchart options:

df: pd.DataFrame,
x: object --> string column name of the violinplot values in the DF for the X
y: object --> string column name of the violinplot values in the DF for the Y
title='' --> string title
xlabel='' --> string x label
ylabel='' --> string y label
hue=None --> column you want to colour by
order=None --> order of your values
hue_order=None,
figsize=(3, 3),
title_font_size=12,
label_font_size=8,
title_font_weight=700,
errwidth=0,
linewidth=1,
edgecolor="k",
config={}

Config options = any of the parameters with the same name but with in a dictionary format instead, and also includes default parameters for the visualisation such as the font family and font.

Example config:

config={'palette': ['red', 'yellow', 'pink'],
       'figsize':(4, 5),  # Size of figure (x, y)
        'title_font_size': 16, # Size of the title (pt)
        'label_font_size': 12, # Size of the labels (pt)
        'title_font_weight': 700, # 700 = bold, 600 = normal, 400 = thin
        'font_family': 'sans-serif', # 'serif', 'sans-serif', or 'monospace'
        'font': ['Tahoma'] # Default: Arial  # http://jonathansoma.com/lede/data-studio/matplotlib/list-all-fonts-available-in-matplotlib-plus-samples/
}

Reading in DF

[1]:
import pandas as pd
from sciviso import Barchart, Boxplot, Heatmap, Histogram, Scatterplot, Violinplot, Volcanoplot, Line
import matplotlib.pyplot as plt

df = pd.read_csv('iris.csv')
x = 'sepal_width'
numeric_cols = ['sepal_width', 'sepal_length', 'petal_length', 'petal_width']
df
[1]:
sepal_length sepal_width petal_length petal_width label
0 5.1 3.5 1.4 0.2 Iris-setosa
1 4.9 3.0 1.4 0.2 Iris-setosa
2 4.7 3.2 1.3 0.2 Iris-setosa
3 4.6 3.1 1.5 0.2 Iris-setosa
4 5.0 3.6 1.4 0.2 Iris-setosa
... ... ... ... ... ...
145 6.7 3.0 5.2 2.3 Iris-virginica
146 6.3 2.5 5.0 1.9 Iris-virginica
147 6.5 3.0 5.2 2.0 Iris-virginica
148 6.2 3.4 5.4 2.3 Iris-virginica
149 5.9 3.0 5.1 1.8 Iris-virginica

150 rows × 5 columns

[2]:
barchart = Barchart(df, x='label', y='petal_width', title='IRIS dataset')
barchart.plot()
plt.show()
../_images/examples_Barchart_3_0.png
[6]:
# barchart = Barchart(df: pd.DataFrame, x: object, y: object, title='', xlabel='', ylabel='', hue=None, order=None,
#                  hue_order=None, figsize=(3, 3), title_font_size=12, label_font_size=8, title_font_weight=700,
#                  errwidth=0, linewidth=1, edgecolor="k", config={})
# Config options = any of the parameters with the same name but with in a dictionary format instead
import seaborn as sns
from matplotlib import rcParams

barchart = Barchart(df=df, x='label', y='petal_width', title='IRIS', xlabel='', ylabel='Petal Witdh',
                    order=['Iris-setosa', 'Iris-virginica', 'Iris-versicolor'],
                    errwidth=0,
                    linewidth=1,
                    edgecolor="black",
                    # You could also pass these as individual parameters, but it's easier to set as a dictionary
                    # also, then you can re-use it for other charts!
                    config={'palette': ['orchid', 'paleturquoise', 'gold'],
                           'figsize':(3, 3),  # Size of figure (x, y)
                           'title_font_size': 16, # Size of the title (pt)
                           'label_font_size': 12, # Size of the labels (pt)
                           'title_font_weight': 700, # 700 = bold, 600 = normal, 400 = thin
                           'font_family': 'sans-serif', # 'serif', 'sans-serif', or 'monospace'
                           'font': ['Tahoma'] # Default: Arial  # http://jonathansoma.com/lede/data-studio/matplotlib/list-all-fonts-available-in-matplotlib-plus-samples/
                           })
barchart.plot()
plt.savefig('barchart.png', dpi=300) # .png, .pdf, .jpg
plt.savefig('barchart.svg', bbox_inches='tight') # .png, .pdf, .jpg

../_images/examples_Barchart_4_0.png