0.99.x 之后的更改#
matplotlib.axes.Axes.set_xlim()
、matplotlib.axes.Axes.set_ylim()
和matplotlib.axes.Axes.axis()
及其对应的 pyplot 函数的默认行为已更改:当使用这些方法之一明确设置视图限制时,匹配轴的自动缩放功能将关闭。一个新的 auto kwarg 可用于控制此行为。限制参数已重命名为 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 kwarg;它是一个要传递给误差条函数的 kwarg 字典。matplotlib.axes.Axes.hist()
的 color kwarg 现在接受颜色规范序列以匹配数据集序列。EllipseCollection
已通过两种方式更改新增了一个 units 选项,'xy',它以数据单位缩放椭圆。这与 :class:'~matplotlib.patches.Ellipse` 的缩放方式一致。
height 和 width kwarg 已更改为指定高度和宽度,再次与
Ellipse
保持一致,并更好地匹配它们的名称;以前它们指定的是半高和半宽。
新增了一个 rc 参数
axes.color_cycle
,并且颜色循环现在独立于 rc 参数lines.color
。matplotlib.Axes.set_default_color_cycle
已弃用。您现在可以将多个图形打印到一个 pdf 文件中,并修改 pdf 文件的文档信息字典。有关更多信息,请参阅
matplotlib.backends.backend_pdf.PdfPages
类的 docstrings。移除了 configobj 和 enthought.traits 包,它们仅由实验性 traited config 需要,并且有些过时。如果需要,请单独安装它们。
新的 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()
将三角形网格绘制为线条和/或标记。