Python Calendar Heatmaps

Publié le: 29 septembre 2020
sur la chaîne: 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');


Sur cette page du site, vous pouvez voir la vidéo en ligne Python Calendar Heatmaps durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Ryan Noonan 29 septembre 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 3,783 fois et il a aimé 61 téléspectateurs. Bon visionnage!