Python Calendar Heatmaps

Veröffentlicht am: 29 September 2020
auf dem Kanal: Ryan Noonan
3,783
61

In this python tutorial, we will go over how to create calendar heatmaps using calmap and calplot.

Calendar heatmaps can be a good way to visualize data trends and patterns by day for a year or several years and provide an overview of the data.

Code Examples on GitHub: https://github.com/groundhogday321/py...

calmap and calplot are similar. calplot is a fork of calmap with the addition of arguments colorbar, dropzero, figsize, suptitle and yearcolor. There might be other slight differences.

In the examples in this tutorial, we are using temperature and precipitation and we want to see which days had the highest temperatures and most precipitation as indicated by the colormap. Some colormaps have a color scheme that might be counter intuitive (i.e.-lighter colors for higher numbers and so on). This can be fixed by reversing the colormap (_r after colormap name) or choosing a different colormap.

Custom colorbars can be created and added with matplotlib. See example below:

import matplotlib as mpl
fig, ax = plt.subplots(figsize=(6,1))
fig.subplots_adjust(bottom=0.5)
cmap = mpl.cm.coolwarm
norm = mpl.colors.Normalize(vmin=temps.min(), vmax=temps.max())
fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap),
cax=ax, orientation='horizontal', label='Some Units');


Auf dieser Seite können Sie das Online-Video Python Calendar Heatmaps mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Ryan Noonan 29 September 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 3,783 Mal angesehen und es wurde von 61 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!