Skip to content

A Python / Matplotlib toolkit to quickly draw business & consulting-style quality plots.

License

Notifications You must be signed in to change notification settings

fvinas/businessplots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

businessplots

A Python / Matplotlib toolkit to quickly draw business & consulting-style quality plots.

Still in early stage! But feel free to test & discuss.

Gallery

Combination of CAGR and difference arrows

Difference arrows of several bars

Usage example:

import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline

from businessplots import arrows
from businessplots import formatters
from businessplots import axis
from businessplots import title

y = [2744000, 3028000, 3257000, 3642000, 3932000, 4314000, 4604000, 5061000, 5464000, 5933000, 6312000, 6879000]
x = [i for i, _ in enumerate(y)]
plt.rcParams['figure.figsize'] = (16.0, 10.0)

fig = plt.figure()

# No arrow
ax1 = fig.add_subplot(221)
ax1.bar(x, y, label="y")
ax1.set_title("No arrow")

# CAGR-like arrow
ax2 = fig.add_subplot(222)
ax2.bar(x, y, label="y")
arrows.increase_arrow()
ax2.set_title("CAGR-like arrow")

# Difference arrow
ax3 = fig.add_subplot(223)
ax3.bar(x, y, label="y")
arrows.increase_arrow(arrow_kind='delta', format_func=formatters.delta_simplified())
axis.yaxis_to_simplified()
ax3.set_title("Difference arrow, unit")

# Other stuff
ax4 = fig.add_subplot(224)
ax4.bar(x, y, label="y")
arrows.increase_arrow(index_from=0, index_to=3, arrow_kind='delta')
arrows.increase_arrow(index_from=4, index_to=7, arrow_kind='delta')
arrows.increase_arrow(index_from=8, index_to=11, arrow_kind='delta')
axis.yaxis_to_simplified()
title.pretty_title(ax4, 'Pretty title', 'Turnover in the last 4 years')

plt.tight_layout()
plt.show()

Usage example

TODO

  • enhance API so that all options can be customized (color, etc.)
  • set a config dict + defaults to easily plot
  • add businessplots.source to quickly add a source below the chart
  • same for ylim, xlim ==> provide a method to auto compute them (==> use ax.margins?)
  • new types of arrows
  • change default font to a beautiful one (if exists)
  • waterfall
  • add support for stacked bars
  • ability to set units once at all

About

A Python / Matplotlib toolkit to quickly draw business & consulting-style quality plots.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages