0.99.x 版本之后的变更#
默认情况下,
matplotlib.axes.Axes.set_xlim()
、matplotlib.axes.Axes.set_ylim()
和matplotlib.axes.Axes.axis()
及其对应的 pyplot 函数的行为已更改:当使用这些方法显式设置视图限制时,匹配轴的自动缩放功能将被关闭。现在可以使用新的 auto kwarg 来控制此行为。限制 kwargs 的名称已更改为 left 和 right,而不是 xmin 和 xmax,以及 bottom 和 top,而不是 ymin 和 ymax。不过,旧名称仍然可以使用。有五个新的 Axes 方法及其对应的 pyplot 函数,用于方便地进行自动缩放、刻度位置、刻度标签格式化,以及刻度和刻度标签的总体外观:
matplotlib.axes.Axes.autoscale()
打开或关闭自动缩放,并应用它。matplotlib.axes.Axes.margins()
设置用于根据matplotlib.axes.Axes.dataLim
自动缩放matplotlib.axes.Axes.viewLim
的边距。matplotlib.axes.Axes.locator_params()
允许调整轴定位器参数,例如 nbins。matplotlib.axes.Axes.ticklabel_format()
是一个方便的方法,用于控制默认与线性轴一起使用的matplotlib.ticker.ScalarFormatter
。matplotlib.axes.Axes.tick_params()
控制刻度及其标签的方向、大小、可见性和颜色。
方法
matplotlib.axes.Axes.bar()
接受一个 error_kw 关键字参数;它是一个字典,包含要传递给 errorbar 函数的 kwargs。现在,
matplotlib.axes.Axes.hist()
的 color 关键字参数接受一个颜色规格序列,以匹配数据集序列。The
EllipseCollection
已经以两种方式进行了更改:有一个新的 units 选项,'xy',它根据数据单位缩放椭圆。这与 :class:'~matplotlib.patches.Ellipse` 的缩放相匹配。
height 和 width kwargs 已更改为指定高度和宽度,以与
Ellipse
保持一致,并更好地匹配它们的名称;以前它们指定的是半高度和半宽度。
有一个新的 rc 参数
axes.color_cycle
,并且颜色循环现在独立于 rc 参数lines.color
。matplotlib.Axes.set_default_color_cycle
已被弃用。你现在可以将多个图形打印到一个PDF文件中,并修改PDF文件的文档信息字典。更多信息请参阅类
matplotlib.backends.backend_pdf.PdfPages
的文档字符串。移除了仅由实验性 traited 配置所需的 configobj 和 enthought.traits 包,这些包有些过时。如有需要,请单独安装。
新的 rc 参数
savefig.extension
设置了当matplotlib.figure.Figure.savefig()
的 fname 参数缺少扩展名时所使用的文件名扩展名。为了简化后端API,所有裁剪矩形和路径现在都使用GraphicsContext对象传递,即使在集合和图像中也是如此。因此:
draw_path_collection(self, master_transform, cliprect, clippath, clippath_trans, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls) # is now draw_path_collection(self, gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls) draw_quad_mesh(self, master_transform, cliprect, clippath, clippath_trans, meshWidth, meshHeight, coordinates, offsets, offsetTrans, facecolors, antialiased, showedges) # is now draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight, coordinates, offsets, offsetTrans, facecolors, antialiased, showedges) draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None) # is now draw_image(self, gc, x, y, im)
有四种新的 Axes 方法及其对应的 pyplot 函数,用于处理非结构化的三角网格:
matplotlib.axes.Axes.tricontour()
在三角网格上绘制等高线。matplotlib.axes.Axes.tricontourf()
在三角网格上绘制填充等高线。matplotlib.axes.Axes.tripcolor()
在三角网格上绘制伪彩色图。matplotlib.axes.Axes.triplot()
绘制一个三角形网格作为线和/或标记。