0.98.0的变化

  • matplotlib.image.imread() 现在不再总是返回rgb a数据---如果图像是亮度或rgb,如果可能,它将返回mxn或mxnx3数组。此外,uint8不再总是强制浮动。
  • 重写 matplotlib.cm.ScalarMappable 要使用的回调基础结构 matplotlib.cbook.CallbackRegistry 而不是自定义回调处理。任何用户 matplotlib.cm.ScalarMappable.add_observerScalarMappable 应该使用 matplotlib.cm.ScalarMappable.callbacksSM CallbackRegistry 相反。
  • 新的轴函数和轴方法提供了对绘图颜色循环的控制: matplotlib.axes.set_default_color_cyclematplotlib.axes.Axes.set_color_cycle .
  • Matplotlib现在需要python 2.4,所以 matplotlib.cbook 将不再提供 setenumerate()reversed()izip 兼容性函数。
  • 在numpy 1.0中,箱仅由左边缘指定。轴法 matplotlib.axes.Axes.hist() 现在使用未来的numpy 1.3语义作为柱状图。提供 binedges ,最后一个值现在给出右上边缘,在numpy 1.0中隐式设置为+无穷大。这也意味着默认情况下,最后一个bin不再包含较高的异常值。
  • 新的轴方法和Pyplot函数, hexbin() ,是替代 scatter() 对于大型数据集。它使一些东西像 pcolor() 二维柱状图,但使用六边形的箱。
  • 新克瓦格 symmetricmatplotlib.ticker.MaxNLocator 允许一个要求一个轴围绕零居中。
  • 工具箱现在必须从导入 mpl_toolkits (不是) matplotlib.toolkits

关于转换重构的注释

0.98系列的一个主要新特性是更灵活和可扩展的转换基础架构,它是用python/numpy编写的,而不是定制的C扩展。

这种重构的主要目标是使Matplotlib更容易扩展以支持新的类型的投影。这主要是一个内部改进,它允许的可能的用户可见的更改还没有到来。

matplotlib.transforms 以描述新的转换框架的设计。

为了提高效率,许多函数将视图返回到numpy数组中。这意味着如果你坚持引用它们,它们的内容可能会改变。如果要存储其当前值的快照,请使用numpy array方法copy()。

现在视图间隔仅存储在一个位置--在 matplotlib.axes.Axes 实例,不在定位器实例中。这意味着定位器必须从 matplotlib.axis.Axis ,然后从 Axes . 如果定位器是临时使用的,并且没有分配给一个或多个轴,(例如 matplotlib.contour )必须创建虚拟轴来存储其边界。呼叫 matplotlib.ticker.TickHelper.create_dummy_axis() 这样做。

的功能 Pbox 已与合并 Bbox . 它的方法现在都返回副本,而不是就地修改。

下面列出了将代码从旧转换框架更新到新转换框架所需的许多简单更改。特别是,返回副本的方法在过去式中用动词命名,而在现在式中用动词命名就地更改对象的方法。

matplotlib.transforms

老方法 新方法
Bbox.get_bounds transforms.Bbox.bounds
Bbox.width transforms.Bbox.width
Bbox.height transforms.Bbox.height
Bbox.intervalx().get_bounds() Bbox.intervalx().set_bounds() transforms.Bbox.intervalx [It is now a property.]
Bbox.intervaly().get_bounds() Bbox.intervaly().set_bounds() transforms.Bbox.intervaly [It is now a property.]
Bbox.xmin transforms.Bbox.x0transforms.Bbox.xmin [1]
Bbox.ymin transforms.Bbox.y0transforms.Bbox.ymin [1]
Bbox.xmax transforms.Bbox.x1transforms.Bbox.xmax [1]
Bbox.ymax transforms.Bbox.y1transforms.Bbox.ymax [1]
Bbox.overlaps(bboxes) Bbox.count_overlaps(bboxes)
bbox_all(bboxes) Bbox.union(bboxes) [It is a staticmethod.]
lbwh_to_bbox(l, b, w, h) Bbox.from_bounds(x0, y0, w, h) [It is a staticmethod.]
inverse_transform_bbox(trans, bbox) Bbox.inverse_transformed(trans)
Interval.contains_open(v) interval_contains_open(tuple, v)
Interval.contains(v) interval_contains(tuple, v)
identity_transform() transforms.IdentityTransform
blend_xy_sep_transform(xtrans, ytrans) blended_transform_factory(xtrans, ytrans)
scale_transform(xs, ys) Affine2D().scale(xs[, ys])
get_bbox_transform(boxin, boxout) BboxTransform(boxin, boxout) or BboxTransformFrom(boxin) or BboxTransformTo(boxout)
Transform.seq_xy_tup(points) Transform.transform(points)
Transform.inverse_xy_tup(points) Transform.inverted() .转换(点)
[1](1, 2, 3, 4) 这个 Bbox 被点(x0,y0)到(x1,y1)绑定,并且这些点没有定义的顺序,也就是说,x0不一定是框的左边缘。以获得 Bbox ,使用只读属性 xmin .

matplotlib.axes

老方法 新方法
Axes.get_position() matplotlib.axes.Axes.get_position() [2]
Axes.set_position() matplotlib.axes.Axes.set_position() [3]
Axes.toggle_log_lineary() matplotlib.axes.Axes.set_yscale() [4]
Subplot 远离的

这个 Polar 类已移动到 matplotlib.projections.polar .

[2]matplotlib.axes.Axes.get_position() 用于返回点列表,现在返回 matplotlib.transforms.Bbox 实例。
[3]matplotlib.axes.Axes.set_position() 现在接受四个标量或 matplotlib.transforms.Bbox 实例。
[4]由于Recfactoring允许两种以上的比例类型(“Log”或“Linear”),因此使用切换不再有意义。 Axes.toggle_log_lineary() 已删除。

matplotlib.artist

老方法 新方法
Artist.set_clip_path(path) Artist.set_clip_path(path, transform) [5]
[5]matplotlib.artist.Artist.set_clip_path() 现在接受 matplotlib.path.Path 实例和A matplotlib.transforms.Transform 将在剪切前立即应用于路径。

matplotlib.collections

老方法 新方法
线型 直线运动 [6]
[6]LineStyles现在被视为所有其他集合属性,即可以提供单个值或多个值。

matplotlib.colors

老方法 新方法
ColorConvertor.to_rgba_list(c) colors.to_rgba_array(c) [matplotlib.colors.to_rgba_array() returns an Nx4 NumPy array of RGBA color quadruples.]

matplotlib.contour

老方法 新方法
Contour._segments matplotlib.contour.Contour.get_paths [Returns a list of matplotlib.path.Path instances.]

matplotlib.figure

老方法 新方法
Figure.dpi.get() Figure.dpi.set() matplotlib.figure.Figure.dpi (财产)

matplotlib.patches

老方法 新方法
Patch.get_verts() matplotlib.patches.Patch.get_path() [Returns a matplotlib.path.Path instance]

matplotlib.backend_bases

老方法 新方法
GraphicsContext.set_clip_rectangle(tuple) GraphicsContext.set_clip_rectangle(bbox)
GraphicsContext.get_clip_path() GraphicsContext.get_clip_path() [7]
GraphicsContext.set_clip_path() GraphicsContext.set_clip_path() [8]
[7]matplotlib.backend_bases.GraphicsContextBase.get_clip_path() 返回窗体的元组( pathaffine_transform 在哪里 path 是一个 matplotlib.path.Path 实例和 affine_transform 是一个 matplotlib.transforms.Affine2D 实例。
[8]matplotlib.backend_bases.GraphicsContextBase.set_clip_path() 现在只接受 matplotlib.transforms.TransformedPath 实例。

RendererBase

新方法:

更改的方法:

删除的方法:

  • draw_arc
  • draw_line_collection
  • draw_line
  • draw_lines
  • draw_point
  • draw_quad_mesh
  • draw_poly_collection
  • draw_polygon
  • draw_rectangle
  • draw_regpoly_collection