In [1]:
%matplotlib inline
from stemgraphic.num import stem_graphic
import pandas as pd
import numpy as np
import math
Loading the iris dataset
In [2]:
df = pd.read_csv('../datasets/iris.csv')
In [3]:
df.describe()
Out[3]:
In [4]:
fig, ax = stem_graphic(df['sepal_length'],
random_state=42,
title='sepal_length')
In [5]:
fig, ax = stem_graphic(df['sepal_width'],
random_state=42,
mirror=True,
title='sepal_width')
Let's combined both variables in one back-to-back stem-and-leaf plot:
In [6]:
fig, ax = stem_graphic(df['sepal_length'],
df['sepal_width'],
random_state=42,
legend_pos=None, outliers=True)
And of course, we can save a pdf. Note the option needed:
fig.savefig('b2b_stem_graphic_numbers.pdf', bbox_inches='tight')
Inverting the two variables, we get
In [7]:
fig, ax = stem_graphic(df['sepal_width'],
df['sepal_length'],
random_state=42,
legend_pos=None)