Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save carloocchiena/99ff13bd34b57ec5fcc3328a492c7fd9 to your computer and use it in GitHub Desktop.
Save carloocchiena/99ff13bd34b57ec5fcc3328a492c7fd9 to your computer and use it in GitHub Desktop.
import matplotlib.dates as mdates
# 1. Riorganizza i dati: pivot con giorni sulle righe, ore sulle colonne
heatmap_data = df.copy()
heatmap_data['Date'] = heatmap_data.index.date
heatmap_data['Hour'] = heatmap_data.index.hour
pivot = heatmap_data.pivot_table(index='Date', columns='Hour', values='Value')
# 2. Plot della heatmap
plt.figure(figsize=(16, 8))
sns.heatmap(pivot, cmap='YlOrRd', cbar_kws={'label': 'Value'})
plt.title('Heatmap Time Series', fontsize=14)
plt.xlabel('Hour of Day')
plt.ylabel('Date')
plt.xticks(rotation=0)
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment