Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output figure size in Jupyter Notebook

I just upgraded my Jupyter version to 4.2.1 and it seems as though inline figures have gotten a lot larger for the same figsize.

Am I imagining this?

Can I change that without changing the figsize?

like image 754
Shahar Avatar asked Jan 20 '17 09:01

Shahar


People also ask

How do I change the size of a figure in jupyter notebook?

Next, to increase the size of the plot in the jupyter notebook use plt. rcParams[“figure. figsize”] method and set width and height of the plot.

How do you get the size of a figure in Python?

Python3. figsize() takes two parameters- width and height (in inches). By default the values for width and height are 6.4 and 4.8 respectively.

How do you change the size of a figure in Python?

If you've already got the figure created, say it's 'figure 1' (that's the default one when you're using pyplot), you can use figure(num=1, figsize=(8, 6), ...) to change it's size etc. If you're using pyplot/pylab and show() to create a popup window, you need to call figure(num=1,...)

Does Jupyter Notebook change the size of the images?

However, the size of the images has changed with a version of Jupyter or matplotlib. The images have become smaller. You can see this by opening and running an example notebook. Matplotlib displays the images smaller than in the example.

How do I visualize part of a long output in Jupyter book?

This allows you to visualize part of a long output without it taking up the entire page. You can trigger this behavior in Jupyter Book by adding the following tag to a cell’s metadata: For example, the following cell has a long output, but will be scrollable in the book:

Can Matplotlib be used with Jupyter?

Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. – matplotlib Within a Jupyter notebook, the data can be visualized with matplotlib. However, the size of the images has changed with a version of Jupyter or matplotlib.

How do I enable output scrolling in Jupyter book?

The traditional Jupyter Notebook interface allows you to toggle output scrolling for your cells. This allows you to visualize part of a long output without it taking up the entire page. You can trigger this behavior in Jupyter Book by adding the following tag to a cell’s metadata: { "tags": [ "output_scroll", ] }


2 Answers

You can use top-level matplotlib settings like this:

import matplotlib as mpl

mpl.rcParams['figure.figsize'] = (10,10)

This will change default figure size to 10x10. More on that in the documentation: http://matplotlib.org/users/customizing.html

like image 129
Sergey Antopolskiy Avatar answered Nov 04 '22 05:11

Sergey Antopolskiy


The scaling of the figure for figures with %matplotlib inline depends on the figure.dpi parameter. So if your figures are to small and you do not want to increase the figsize then you can just set

import matplotlib.pyplot as plt
plt.rcParams['figure.dpi'] = 150 # default for me was 75

I also had the impression that the scaling changed at some point, but I guess this can also appear if you change your screen/resolution.

like image 41
AS1 Avatar answered Nov 04 '22 05:11

AS1