I am looking to replicate the image below in a pandas dataframe within a Jupyter notebook. The title of orders in 2020 is not needed. I discovered this page https://github.com/crdietrich/sparklines/blob/master/Pandas%20Sparklines%20Demo.ipynb which seems to add sparklines within a dataframe, but not a bar chart. Any insight would be much appreciated! Code below provides sparklines in a dataframe column, but as shown in the image I'd like stacked bars with the below example data.
# example data
data = [[20, 10], [50, 15], [6, 14]]
# Create the pandas DataFrame
df = pd.DataFrame(data, columns=['Orchid', 'Rose'])
# print dataframe.
print(df)
Output I am looking for should look similiar to the below image.
Example code that shows sparklines in a column, but not stacked bars.
import numpy as np
import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
%matplotlib inline
import sparklines
# Create some data
density_func = 78
mean, var, skew, kurt = stats.chi.stats(density_func, moments='mvsk')
x_chi = np.linspace(stats.chi.ppf(0.01, density_func),
stats.chi.ppf(0.99, density_func), 100)
y_chi = stats.chi.pdf(x_chi, density_func)
x_expon = np.linspace(stats.expon.ppf(0.01), stats.expon.ppf(0.99), 100)
y_expon = stats.expon.pdf(x_expon)
a_gamma = 1.99
x_gamma = np.linspace(stats.gamma.ppf(0.01, a_gamma),
stats.gamma.ppf(0.99, a_gamma), 100)
y_gamma = stats.gamma.pdf(x_gamma, a_gamma)
n = 100
np.random.seed(0) # keep generated data the same for git commit
data = [np.random.rand(n),
np.random.randn(n),
np.random.beta(2, 1, size=n),
np.random.binomial(3.4, 0.22, size=n),
np.random.exponential(size=n),
np.random.geometric(0.5, size=n),
np.random.laplace(size=n),
y_chi,
y_expon,
y_gamma]
function = ['rand',
'randn',
'beta',
'binomial',
'exponential',
'geometric',
'laplace',
'chi',
'expon',
'gamma']
df = pd.DataFrame(data)
df['function'] = function
df
# Define range of data to make sparklines
a = df.ix[:, 0:100]
# Output to new DataFrame of Sparklines
df_out = pd.DataFrame()
df_out['sparkline'] = sparklines.create(data=a)
sparklines.show(df_out[['sparkline']])
# Insert Sparklines into source DataFrame
df['sparkline'] = sparklines.create(data=a)
sparklines.show(df[['function', 'sparkline']])
# Detailed Formatting
df_out = pd.DataFrame()
df_out['sparkline'] = sparklines.create(data=a,
color='#1b470a',
fill_color='#99a894',
fill_alpha=0.2,
point_color='blue',
point_fill='none',
point_marker='*',
point_size=3,
figsize=(6, 0.25))
sparklines.show(df_out[['sparkline']])
# Example Data and Sparklines Layout
df_copy = df[['function', 'sparkline']].copy()
df_copy['value'] = df.ix[:, 100]
df_copy['change'] = df.ix[:,98] - df.ix[:,99]
df_copy['change_%'] = df_copy.change / df.ix[:,99]
sparklines.show(df_copy)

You could tweak it with the Styler, using a hacky
bar:Output (in Notebook) :
Used input (
df) :