Skip to main content

Calendar heatmaps from Pandas time series data

Project description

Calplot creates heatmaps from Pandas time series data.

Plot Pandas time series data sampled by day in a heatmap per calendar year, similar to GitHub’s contributions plot, using matplotlib.

Installation

To install the latest release via PyPI using pip:

pip install calplot

Usage

For detailed usage of this library, refer to the documentation.

The following examples are run in a Jupyter notebook.

import calplot
import numpy as np; np.random.seed(sum(map(ord, 'calplot')))
import pandas as pd
all_days = pd.date_range('1/1/2019', periods=730, freq='D')
days = np.random.choice(all_days, 500)
events = pd.Series(np.random.randn(len(days)), index=days)
calplot.calplot(events)
Example calendar heatmap with default configuration
all_days = pd.date_range('1/1/2019', periods=360, freq='D')
days = np.random.choice(all_days, 500)
events = pd.Series(np.random.randn(len(days)), index=days)
calplot.calplot(events, edgecolor=None, cmap='YlGn')
Example calendar heatmap with edgecolor set to None
calplot.calplot(events, yearcolor=black, cmap='YlGn')
Example calendar heatmap with yearcolor set to black
calplot.calplot(events, textformat='{:.0f}', textfiller='-', cmap='YlGn')
Example calendar heatmap with textformat and textfiller set
calplot.calplot(events, dropzero=False, cmap='YlGn')
Example calendar heatmap with dropzero set to False
calplot.calplot(events, colorbar=False, suptitle='Random data from standard normal distribution', cmap='YlGn')
Example calendar heatmap with colorbar set to False and suptitle set
calplot.calplot(events, linewidth=0, cmap='YlGn')
Example calendar heatmap with linewidth set to 0

Changelog

Package calplot is a fork of calmap 0.0.7-dev with the following changes and additions.

Todo

  • Adding argument startday for function calplot and yearplot to specify the index representing the day of week of the first day in each week in the generated plot. Defaults to 0, which represents Monday. (Implementation of this require non-trivial change to existing code that is inherited from calmap or taken from other projects, including code for pivoting of by_days DataFrame, and for calculation of polygon coordinates for month borders, in addition to new code to handle the ordering of items in daylabels list.)

Since version 0.1.6 (Dec 2020):

  • Added argument textformat for function calplot and yearplot to specify the text format string for grid cell text. Defaults to empty string. Note that text plotting is turned off by setting the argument to empty string.

  • Added argument textfiller for function calplot and yearplot to specify the fallback text for grid cell text. Defaults to empty string.

  • Added argument textcolor for function calplot and yearplot to specify the text color for grid cell text. Defaults to black.

Since version 0.1.5 (Dec 2020):

  • Added argument edgecolor for function calplot and yearplot to specify color of seperation lines between months. Defaults to gray. Note that lines can be turned off by setting the argument to None without quotes.

Since version 0.1.3 (Aug 2020):

  • Removed legacy code for compatibility to fix a FutureWarning in yearplot. Note that pandas>=1.1 is now required to install the package.

Since version 0.1.2 (Jan 2020):

  • Added argument dropzero for function calplot and yearplot to specify whether to not fill a cell with a color for days with a zero value. Defaults to True.

Since version 0.1.1 (Jan 2020):

  • Renamed function calendarplot to calplot.

  • Added argument colorbar for function calplot to display a colorbar to the right of the heatmap if more than one unique values in plot. Defaults to True.

  • Added argument figsize for function calplot. Defaults to a tighter layout automatically adjusted to fit the number of years in plot.

  • Added argument suptitle for function calplot. Defaults to None.

  • Added argument yearcolor for function calplot. Defaults to lightgray. Note that the default color is in contrast to whitesmoke, which is the default value for fillcolor.

  • Added argument monthlabelha for function calplot and yearplot to specify horizontal alignment for month labels. Defaults to center.

  • Changed default colormap cmap for function calplot to viridis.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

calplot-0.1.6.3.tar.gz (9.6 kB view hashes)

Uploaded Source

Built Distribution

calplot-0.1.6.3-py3-none-any.whl (11.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page