如何在 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
How to increase image size of pandas.DataFrame.plot in jupyter notebook?
提问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));
df.plot(figsize=(10,5));
EDIT
编辑
The size in figsize=(10,5)
is given in inches
, unless dpi
param 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]