我在Ipython Notebook上使用“%matplotlib inline”使我的绘图内联。
现在,情节出现了。然而,它非常小。有没有办法让它看起来更大使用笔记本设置或情节设置?
我在Ipython Notebook上使用“%matplotlib inline”使我的绘图内联。
现在,情节出现了。然而,它非常小。有没有办法让它看起来更大使用笔记本设置或情节设置?
当前回答
用类似这样的话:
import matplotlib.pyplot as plt
%matplotlib inline
plt.subplots(figsize=(18,8 ))
plt.subplot(1,3,1)
plt.subplot(1,3,2)
plt.subplot(1,3,3)
命令的输出
其他回答
调整一个人物的大小:
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15, 15))
更改默认设置,从而更改所有的情节:
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = [15, 15]
可以将图缩放到整个单元格宽度。
主要绘制折线图时,使用svg格式代替位图:
%config InlineBackend.figure_format = 'svg'
强制绘图为100%宽度(粘贴到一个空单元格中):
%%html
<style>
.output_svg div{
width: 100% !important;
height: 100% !important;
}
</style>
您可能还想根据其他答案更改纵横比或其他参数,以便更好地了解。
它没有使用公共API,可能有一天会停止工作。
这个问题是关于matplotlib的,但是为了任何一个R用户,在这里给出了一个语言无关的标题:
如果你正在使用R内核,只需使用:
options(repr.plot.width=4, repr.plot.height=3)
我发现%matplotlib笔记本比内嵌Jupyter笔记本更适合我。
注意,如果之前使用了%matplotlib内联,可能需要重新启动内核。
2019年更新: 如果您正在运行Jupyter实验室,您可能需要使用 % matplotlib小部件
用类似这样的话:
import matplotlib.pyplot as plt
%matplotlib inline
plt.subplots(figsize=(18,8 ))
plt.subplot(1,3,1)
plt.subplot(1,3,2)
plt.subplot(1,3,3)
命令的输出