I'm plotting a heatmap that relates number of cases, age range and date. However I couldn't reduce the x-axis label to %d-%b (e.g., 15-Dec). How can I change this? My data is in Pastebin.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
df_general = pd.read_csv('df_general.csv')
df_general['Date'] = pd.to_datetime(df_general['Date'])
fig = plt.figure(figsize = (15,5))
y_axis_labels = ['0 to 1', '1 to 9', '10 to 19', '20 to 29', '30 to 39',
'40 to 49', '50 to 59', '60 to 69', '70 to 79', '80 to 89',
'> 90']
covid_matrix = df_general.pivot('FAIXA_ETARIA', 'Date', 'count')
sns.heatmap(covid_matrix, xticklabels = 30, yticklabels = y_axis_labels, cmap='coolwarm')
#x-axis ticklabels between 30 dates
When I define a list with specific labels, adding m e replacing xticklabels value, the graph gets worse:
m = ('01-Jan', '01-Fev', '01-Mar', '01-Apr', '01-May', '01-Jun', '01-Jul', '01-Ago', '01-Sep', '01-Oct', '01-Nov', '01-Dec')
sns.heatmap(covid_matrix, xticklabels = m, yticklabels = y_axis_labels, cmap='coolwarm')
#x-axis ticklabels with m value
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…