简体   繁体   English

使用 %matplotlib 笔记本时修复 Jupyter 笔记本中的绘图

[英]Fixing plots in Jupyter notebook when using %matplotlib notebook

I am using %matplotlib notebook in Jupyter notebook however, most of my plots get cutout like the image below?我在 Jupyter 笔记本中使用 %matplotlib 笔记本,但是,我的大部分绘图都像下图一样被剪掉了? Could anyone help please so that the plots are generated in full view?任何人都可以帮忙,以便在全视图中生成地块吗?

Image I am trying to fit in full view我正在尝试以全视图显示的图像

Thank you for the help.感谢您的帮助。

Before you plot, I assume you are using:在您使用 plot 之前,我假设您正在使用:

plt.figure(figsize=(some_dimension,some_dimension))

You can try reducing the figsize to make your graph fit您可以尝试减少 figsize 以使您的图形适合

You can use:您可以使用:

matplotlib.pyplot.margins(*margins, x=None, y=None, tight=True)

*margins: float, optional If a single positional argument is provided, it specifies both margins of the x-axis and y-axis limits. *margins: float, optional 如果提供了单个位置参数,它指定 x 轴和 y 轴范围的边距。 If two positional arguments are provided, they will be interpreted as xmargin, ymargin.如果提供了两个位置 arguments,它们将被解释为 xmargin,ymargin。 If setting the margin on a single axis is desired, use the keyword arguments described below.如果需要在单个轴上设置边距,请使用如下所述的关键字 arguments。

x, y: float, optional Specific margin values for the x-axis and y-axis, respectively. x, y: float, optional 分别为 x 轴和 y 轴的特定边距值。 These cannot be used with positional arguments, but can be used individually to alter on eg, only the y-axis.这些不能与位置 arguments 一起使用,但可以单独用于改变,例如,仅 y 轴。

tight: bool or None, default is True The tight parameter is passed to autoscale_view(), which is executed after a margin is changed;紧:bool或None,默认为True将紧参数传递给autoscale_view(),在margin改变后执行; the default here is True, on the assumption that when margins are specified, no additional padding to match tick marks is usually desired.这里的默认值为 True,假设当指定边距时,通常不需要额外的填充来匹配刻度线。 Set tight to None will preserve the previous setting.设置为 None 将保留以前的设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM