Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to increase the size of Jupyter notebook plot

Using the calmap package I create a heatmap calendar but I would like to know how to increase the font or the size of the plot.

import numpy as np; np.random.seed(sum(map(ord, 'calmap')))
import pandas as pd
import calmap

all_days = pd.date_range('1/15/2014', periods=700, freq='D')
days = np.random.choice(all_days, 500)
events = pd.Series(np.random.randn(len(days)), index=days)

calmap.yearplot(events, year=2015)

enter image description here

like image 878
Papouche Guinslyzinho Avatar asked Jul 19 '18 07:07

Papouche Guinslyzinho


2 Answers

This should fix your issue

import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"]=20,20
like image 150
Inder Avatar answered Sep 17 '22 17:09

Inder


Based on the documentation:

def yearplot(data, year=None, how='sum', vmin=None, vmax=None, cmap='Reds',
         fillcolor='whitesmoke', linewidth=1, linecolor=None,
         daylabels=calendar.day_abbr[:], dayticks=True,
         monthlabels=calendar.month_abbr[1:], monthticks=True, ax=None,
         **kwargs):

There is an ax parameter. It corresponds to the axis on which the figure must be draw. First create an axis with the desired size.

from matplotlib import pyplot as plt

f, ax = plt.subplots(1, 1, figsize = (15, 10))
calmap.yearplot(events, year=2015, ax=ax)

EDIT: For font size, work on the axis. Something like this:

for item in ([ax.title, ax.xaxis.label, ax.yaxis.label] +
         ax.get_xticklabels() + ax.get_yticklabels()):
    item.set_fontsize(20)
like image 39
Mathieu Avatar answered Sep 19 '22 17:09

Mathieu