如何在 jupyter notebook 中增加 pandas.DataFrame.plot 的图像大小?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51174691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 16:14:39  来源:igfitidea点击:

How to increase image size of pandas.DataFrame.plot in jupyter notebook?

pandasmatplotlibipythonjupyter

提问by mommomonthewind

How can I modify the size of the output image of the function pandas.DataFrame.plot?

如何修改函数输出图像的大小pandas.DataFrame.plot

I tried:

我试过:

plt.figure (figsize=(10,5))

plt.figure (figsize=(10,5))

and

%matplotlib notebook

%matplotlib notebook

but none of them work.

但它们都不起作用。

回答by Sergey Bushmanov

Try this:

尝试这个:

df = pd.DataFrame({"a":[1,2],"b":[1,2]})
df.plot(figsize=(5,5));

enter image description here

在此处输入图片说明

df.plot(figsize=(10,5));

enter image description here

在此处输入图片说明

EDIT

编辑

The size in figsize=(10,5)is given in inches, unless dpiparam is specified, when it would be in pixels.

in 的大小在figsize=(10,5)中给出inches,除非dpi指定了 param ,否则它将以像素为单位。

https://matplotlib.org/api/_as_gen/matplotlib.pyplot.figure.html#matplotlib.pyplot.figure

https://matplotlib.org/api/_as_gen/matplotlib.pyplot.figure.html#matplotlib.pyplot.figure

回答by black_fm

If you want to make a change global to the whole notebook:

如果要对整个笔记本进行全局更改:

import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams["figure.figsize"] = [10, 5]