API更改¶
如果更新Matplotlib会破坏脚本,此列表可能会帮助您找出导致中断的原因以及如何通过更新代码来修复它。
有关旧版本中的API更改,请参见
下面列出了最新版本的更改。有关添加到Matplotlib的新功能,请参见 有什么新鲜事吗?
API对3.3.1的更改¶
贬抑¶
还原了对 num2epoch
和 epoch2num
¶
这两个函数在3.3.0中被弃用,并且没有相对于新的Matplotlib epoch处理返回准确的Matplotlib datenum (get_epoch
和 rcParams["date.epoch"]
(default: '1970-01-01T00:00:00'
) ). 此版本还原了弃用。
功能 epoch2num
和 dates.julian2num
使用 date.epoch
RCPARAM¶
现在 epoch2num
和(无文件) julian2num
返回浮点天数自 get_epoch
由设置 rcParams["date.epoch"]
(default: '1970-01-01T00:00:00'
) ,而不是“0000-12-31T00:00:00”旧纪元以来的浮点天数。如果需要,可以根据需要将新值转换为旧值 old = new + mdates.date2num(np.datetime64('0000-12-31'))
3.3.0的API更改¶
行为改变¶
Formatter.fix_minus
¶
Formatter.fix_minus
now performs hyphen-to-unicode-minus replacement
whenever rcParams["axes.unicode_minus"]
(default: True
) is True; i.e. its behavior matches the one
of ScalarFormatter.fix_minus
(ScalarFormatter
now just inherits that
implementation).
此替换现在由 format_data_short
方法,它影响GUI工具栏中的光标值。
FigureCanvasBase
现在总是有一个 manager
属性,该属性可能为“无”¶
以前,它不一定有这样的属性。支票 hasattr(figure.canvas, "manager")
现在应替换为 figure.canvas.manager is not None
(或) getattr(figure.canvas, "manager", None) is not None
背面兼容性)。
cbook.CallbackRegistry
当GUI没有异常运行时,事件传播循环¶
cbook.CallbackRegistry
现在默认为在没有交互式GUI事件循环运行时传播回调抛出的异常。如果GUI事件循环 is 跑步, cbook.CallbackRegistry
仍然默认只打印回溯,因为未处理的异常可以使程序完全恢复 abort()
在这种情况下。
Axes.locator_params()
验证 axis
参数¶
axes.Axes.locator_params
用于接受 axis
当传递一个不支持的值时,默默地什么也不做。它现在引发了一场争论 ValueError
.
Axis.set_tick_params()
验证 which
参数¶
Axis.set_tick_params
(以及更高级别) axes.Axes.tick_params
和 pyplot.tick_params
)用于接受 which
当传递一个不支持的值时,默默地什么也不做。它现在引发了一场争论 ValueError
.
Axis.set_ticklabels()
must match FixedLocator.locs
¶
如果轴使用 ticker.FixedLocator
,通常通过调用 Axis.set_ticks
,则提供的标签数必须与可用位置数匹配 (FixedFormattor.locs
). 如果不是,一个 ValueError
提高了。
backend_pgf.LatexManager.latex
¶
backend_pgf.LatexManager.latex
现在使用 encoding="utf-8"
,所以 stdin
, stdout
和 stderr
属性是utf8编码的。
pyplot.xticks()
and pyplot.yticks()
¶
以前,传递标签时不将记号传递给 pyplot.xticks
和 pyplot.yticks
会导致
TypeError:类型为“NoneType”的对象没有len()
它现在引发了一场争论 TypeError
正确描述错误。
在多个别名下设置同一属性现在会引发TypeError¶
以前打过电话,例如。 plot(..., color=somecolor, c=othercolor)
会发出警告因为 color
和 c
实际上映射到同一艺术家属性。这将引发一个TypeError。
FileMovieWriter
临时框架目录¶
FileMovieWriter
现在默认为在临时目录中写入临时帧,该目录在退出时总是被清除。为了保持文件系统上保存的单个帧,传递一个显式的 frame_prefix .
Axes.plot
不再接受 x 和 y 既有二维的,又有不同列数的¶
以前,打电话 Axes.plot
e、 g.与 x 形状 (n, 3)
和 y 形状 (n, 2)
将绘制 x 在第一列 y ,第二列 x 对第二列 y , and 第一列 x 对抗第三纵队 y . 这将引发一个错误。
Text.update_from
现在从源文本复制usetex状态¶
stem
now defaults to use_line_collection=True
¶
这会将干图创建为 LineCollection
而不是个人 Line2D
对象,大大提高了性能。
rcParams颜色验证器现在更严格了¶
以前,rcParams的值类似于颜色的条目在字符串的“中间”接受“虚假”的额外字母或字符,例如。 "(0, 1a, '0.5')"
会被解释为 (0, 1, 0.5)
. 这些额外的字符(包括内部引号)现在会引发ValueError。
SymLogNorm
现在有一个 base 参数¶
以前, SymLogNorm
没有 base 关键字参数,并默认为 base=np.e
文件上说是 base=10
. 在准备设置默认值10时,调用 SymLogNorm
没有新的 base 关键字参数发出弃用警告。
rcsetup.validate_color_for_prop_cycle
现在总是为字节输入引发TypeError¶
它以前提出过 TypeError
, 除了 当输入是表单的 b"C[number]"
在这种情况下,它引发了一个ValueError。
FigureCanvasPS.print_ps
和 FigureCanvasPS.print_eps
不再应用edgecolor和facecolor¶
这些方法现在假设图形的边和面颜色已经被 FigureCanvasBase.print_figure
,因为他们通常被称为通过它。
此行为与其他图形保存方法一致 (FigureCanvasAgg.print_png
, FigureCanvasPdf.print_pdf
, FigureCanvasSVG.print_svg
)
pyplot.subplot()
如果给定的参数数目不正确,则引发TypeError¶
这与其他签名不匹配错误是一致的。以前引发了ValueError。
关闭所有图形的快捷方式¶
关闭所有图形的快捷方式现在也适用于经典工具栏。没有任何默认的快捷方式,因为无意中关闭所有数字按一个键可能太容易发生。您可以自己使用配置快捷方式 rcParams["keymap.quit_all"]
(default: []
) .
自动缩放箭头¶
打电话斧头箭头()现在将自动缩放轴。
set_tick_params(label1On=False)
现在还使偏移文本(如果有)不可见¶
... 因为偏移文本在没有记号标签的情况下很难被解释。
Axes.annotate
和 pyplot.annotate
参数名称已更改¶
参数 s
到 Axes.annotate
和 pyplot.annotate
已重命名为 text
,匹配 Annotation
.
旧参数名仍受支持,但在将来的Matplotlib版本中将不再支持它。
font_manager.json_dump
现在锁定字体管理器转储文件¶
... 防止多个进程同时写入。
pyplot.rgrids
和 pyplot.thetagrids
现在当只使用kwargs调用时也充当setters¶
以前,当没有给出位置参数时,关键字参数会被忽略。
Axis.get_minorticklabels
和 Axis.get_majorticklabels
现在返回普通列表¶
以前, Axis.get_minorticklabels
和 Axis.get_majorticklabels
静默列表返回。它们的返回类型现在更改为普通列表。 get_xminorticklabels
, get_yminorticklabels
, get_zminorticklabels
, Axis.get_ticklabels
, get_xmajorticklabels
, get_ymajorticklabels
和 get_zmajorticklabels
方法将受到此更改的影响。
默认滑块格式化程序¶
用于设置格式的默认方法 Slider
值已更改为使用 ScalarFormatter
调整滑块值限制。如果值比1大得多,则应确保显示的值比1小得多。若要还原旧行为,请显式传递“%1.2f”作为 瓦尔夫特 参数到 Slider
.
添加 归一化 关键字参数 Axes.pie
¶
pie()
用于在值之和小于1时绘制部分饼图。此行为已弃用,默认情况下将更改为始终将值规范化为完整饼图。如果你想画一个局部派,请通过 normalize=False
明确地。
table.CustomCell
is now an alias for table.Cell
¶
的所有功能 CustomCell
已移到其基类 Cell
.
wx定时器间隔¶
计时器上的间隔设置尚未启动 TimerWx
不会再启动了。
Legend
和 OffsetBox
能见度¶
Legend
和 OffsetBox
子类 (PaddedBox
, AnchoredOffsetbox
和 AnnotationBbox
)不再直接跟踪其底层的可见性 Patch
艺术家,而是把国旗传给 Patch
.
Legend
和 Table
不再允许无效位置¶
这会影响轴上生成的图例 (Axes.legend
和 pyplot.legend
)在一个数字上 (Figure.legend
和 pyplot.figlegend
). 图例也不再接受不支持的 'best'
位置。以前,将使用无效的轴位置 'best'
将使用无效的图形位置 'upper right'
.
传递Line2D 绘画风格 与 线型 被移除¶
而不是 plt.plot(..., linestyle="steps--")
使用 plt.plot(..., linestyle="--", drawstyle="steps")
. ds
也是的别名 drawstyle
.
大写颜色字符串¶
支持将单字母颜色(“rgbcmykw”之一)作为大写字符传递;这些颜色现在区分大小写(小写)。
紧凑/受限的布局不再担心标题太宽¶
tight_layout 和 constrained_layout 收缩轴以适应轴上的“装饰”。但是,如果xlabel或title在x方向上太长,则使轴在x方向上变小没有帮助。两者的行为都已更改为忽略布局逻辑中标题和xlabel的宽度以及ylabel的高度。
这也意味着有一个新的关键字参数 axes.Axes.get_tightbbox
和 axis.Axis.get_tightbbox
: for_layout_only
,默认为 假 但如果 True 使用上述规则返回边界框。
rcParams["savefig.facecolor"]
(default: 'auto'
) 和 rcParams["savefig.edgecolor"]
(default: 'auto'
) 现在默认为“自动”¶
此新允许的值 rcParams["savefig.facecolor"]
(default: 'auto'
) 和 rcParams["savefig.edgecolor"]
(default: 'auto'
) 以及 脸色 和 变色染料 参数到 Figure.savefig
,表示“使用当前图形的任何facecolor和edgecolor”。
使用单个数据集时, Axes.hist
不再将添加的艺术家包装在 silent_list
¶
什么时候? Axes.hist
使用单个数据集调用时,它会将 BarContainer
对象(当 histtype="bar"
或 "barstacked"
) Polygon
对象(当 histype="step"
或 "stepfilled"
)--后者被包装在一个元素的列表中。以前,任何一位艺术家都会被包裹在 silent_list
. 情况已不再是这样了 BarContainer
现在按原样返回(如果您直接依赖于具体的 list
API;但是, BarContainer
继承自 tuple
因此,大多数常见的操作仍然可用),并且 Polygon
按原样返回。这使得 repr
更准确地说:现在是:
<BarContainer object of of 10 artists> # "bar", "barstacked"
[<matplotlib.patches.Polygon object at 0xdeadbeef>] # "step", "stepfilled"
而不是::
<a list of 10 Patch objects> # "bar", "barstacked"
<a list of 1 Patch objects> # "step", "stepfilled"
什么时候? Axes.hist
如果使用多个艺术家调用,它仍将其返回值包装在 silent_list
,但使用更精确的类型信息:
<a list of 3 BarContainer objects> # "bar", "barstacked"
<a list of 3 List[Polygon] objects> # "step", "stepfilled"
而不是::
<a list of 3 Lists of Patches objects> # "bar", "barstacked"
<a list of 3 Lists of Patches objects> # "step", "stepfilled"
默认情况下,Qt和wx后端不再创建状态栏¶
坐标信息现在显示在工具栏中,与其他后端保持一致。这是为了简化Matplotlib在更大的gui中的嵌入,Matplotlib可以控制工具栏,但不能控制状态栏。
rcParams["text.hinting"]
(default: 'force_autohint'
) 现在支持名称映射到FreeType标志¶
rcParams["text.hinting"]
(default: 'force_autohint'
) 现在支持值“default”、“nou autohint”、“forceu autohint”和“nou hinting”,这些值直接映射到FreeType标志FTu LOADu default等。仍然支持旧的同义词(分别为“任一”、“本机”、“自动”和“无”),但不鼓励使用它们。要获取标准化值,请使用 backend_agg.get_hinting_flag
,返回整型标志值。
cbook.get_sample_data
自动加载numpy数组¶
什么时候? cbook.get_sample_data
用于加载npy或npz文件以及仅关键字参数 np_load
如果为True,则使用 numpy.load
. np_load
对于向后兼容性,默认值为False,但在以后的版本中将变为True。
get_text_width_height_descent
now checks ismath
rather than rcParams["text.usetex"]
(default: False
)¶
... 确定字符串是否应传递给usetex机器。这样即使rcParam为True,也可以将单个字符串标记为not usetex。
Axes.vlines
, Axes.hlines
, pyplot.vlines
and pyplot.hlines
colors parameter default change¶
这个 ** 参数现在将默认为 rcParams["lines.color"]
(default: 'C0'
) ,而以前它默认为“k”。
自动缩放clim-in ScalerMappable
班¶
以前的一些打印方法会将自动缩放推迟到第一次绘制,如果只有一个 vmin 或 vmax 传递了关键字参数 (Axes.scatter
, Axes.hexbin
, Axes.imshow
, Axes.pcolorfast
)但是如果两个都没有通过(独立于 norm 关键字参数)。其他方法 (Axes.pcolor
, Axes.pcolormesh
)总是根据初始数据自动缩放。
所有的绘图方法现在都解决了未设置的问题 vmin 或 vmax 在初始调用时使用传入的数据。
如果你只依靠 vmin 或 vmax 在调用方法和第一次呈现图形之间保持未设置状态,通过手动将相关限制设置回 None
::
cm_obj.norm.vmin = None
# or
cm_obj.norm.vmax = None
将在绘制过程中解决。
贬抑¶
figure.add_axes()
没有争论¶
调用 fig.add_axes()
如果没有参数,则当前不执行任何操作。此调用将在将来引发错误。添加自由浮动轴需要一个位置矩形。如果要填充单轴的图形,请使用 add_subplot()
相反。
backend_wx.DEBUG_MSG
¶
backend_wx.DEBUG_MSG
已弃用。wx后端现在使用常规日志记录。
Colorbar.config_axis()
¶
Colorbar.config_axis()
被认为是内部的。不赞成使用它。
NonUniformImage.is_grayscale
and PcolorImage.is_grayscale
¶
为了与一致性,这些属性已弃用 AxesImage.is_grayscale
,在Matplotlib 2.0.0中被删除。(请注意,以前,这些属性仅可用 渲染图像后 )
den
parameter and attribute to mpl_toolkits.axisartist.angle_helper
¶
对于中定义的所有定位器类 mpl_toolkits.axisartist.angle_helper
, the den
参数已重命名为 nbins
和 den
属性已弃用,取而代之的是其(先前存在的)同义词 nbins
,以与中定义的定位器类保持一致 matplotlib.ticker
.
backend_pgf.LatexManager.latex_stdin_utf8
¶
backend_pgf.LatexManager.latex
现在使用 encoding="utf-8"
,所以 stdin
属性已经是utf8编码的;属性 latex_stdin_utf8
属性因此被弃用。
包含“U”的标志传递给 cbook.to_filehandle
和 cbook.open_file_cm
¶
请从传递给的标志中删除“U” cbook.to_filehandle
和 cbook.open_file_cm
. 这与他们被驱逐出境是一致的 open
在python3.9中。
PDF和PS字符跟踪内部¶
这个 used_characters
属性与 track_characters
和 merge_used_characters
方法 RendererPdf
, PdfFile
和 RendererPS
被贬低。
不区分大小写的capstyles和joinstyles¶
请以小写形式传递capstyles(“斜接”、“圆形”、“斜角”)和jointstyles(“对接”、“圆形”、“突出”)。
将原始数据传递给 register_cmap()
¶
通过参数传递原始数据 data 和 lut 到 register_cmap()
已弃用。相反,显式地创建 LinearSegmentedColormap
并通过 cmap 参数: register_cmap(cmap=LinearSegmentedColormap(name, data, lut))
.
DateFormatter.illegal_s
¶
此属性未使用且已弃用。
widgets.TextBox.params_to_disable
¶
此属性已弃用。
还原折旧 * 最小值, * 最大关键字参数 set_x/y/zlim_3d()
¶
在3.0中,这些关键字参数以及中相应的参数都已弃用 set_xlim()
/ set_ylim()
. 2D版本的弃用已经在3.1中恢复。
cbook.local_over_kwdict
¶
此函数已弃用。使用 cbook.normalize_kwargs
相反。
传递单数和复数 ** , 线宽度 , 直线运动 到 Axes.eventplot
¶
通过,例如两个 线宽 和 线宽度 将在将来引发TypeError。
设置 rcParams["text.latex.preamble"]
(default: ''
) 或 rcParams["pdf.preamble"]
到非字符串¶
这些rcParams应设置为字符串值。不赞成支持None(表示空字符串)和字符串列表(以换行符隐式连接)。
参数 norm 和 vmin / vmax 不应同时使用¶
传递参数 norm 和 vmin / vmax 同时使用colormapping等函数 scatter()
和 imshow()
已弃用。代替Ine norm=LogNorm(), vmin=min_val, vmax=max_val
通过 norm=LogNorm(min_val, max_val)
. vmin 和 vmax 只能在没有设置的情况下使用 norm .
非有效参数 Figure.colorbar
和 matplotlib.colorbar.Colorbar
¶
这个 cmap 和 norm 参数 Figure.colorbar
和 matplotlib.colorbar.Colorbar
因此,它们总是不受映射规范的影响。同样,通过 阿尔法 , 边界 , 价值观 , 延伸 或 填满 带有 ContourSet
可映射,或 阿尔法 带有 Artist
不推荐使用mappable,因为mappable同样会覆盖它们。
args_key
和 exec_key
内建属性 MovieWriter
的S¶
这些属性已弃用。
未使用的参数¶
以下参数没有任何效果,不推荐使用:
- 任意关键字参数
StreamplotSet
- 参数 量化 属于
Path.cleaned()
- 参数 s 属于
AnnotationBbox.get_fontsize()
- 参数 标签 属于
Tick
Axes.update_datalim_bounds
¶
此方法已弃用。使用 ax.dataLim.set(Bbox.union([ax.dataLim, bounds]))
相反。
{,Symmetrical}LogScale.{,Inverted}LogTransform
¶
LogScale.LogTransform
, LogScale.InvertedLogTransform
, SymmetricalScale.SymmetricalTransform
和 SymmetricalScale.InvertedSymmetricalTransform
已弃用。直接从 scale
模块。
TexManager.cachedir
, TexManager.rgba_arrayd
¶
使用 matplotlib.get_cachedir()
取而代之的是前者;后者没有替代品。
设置 Line2D
的pickradius通过 Line2D.set_picker
¶
设置一个 Line2D
的pickradius(即pick事件和包含检查的容差)通过 Line2D.set_picker
已弃用。使用 Line2D.set_pickradius
相反。
Line2D.set_picker
不再设置艺术家的自定义-contain()检查。
Artist.set_contains
, Artist.get_contains
¶
设置自定义方法重写 Artist.contains
已弃用。没有替换项,但仍可以使用自定义pick事件 Artist.set_picker
.
Colorbar
方法¶
这个 on_mappable_changed
和 update_bruteforce
方法 Colorbar
已弃用;两者都可以由对的调用替换 update_normal
.
OldScalarFormatter
, IndexFormatter
and DateIndexFormatter
¶
这些格式化程序已弃用。它们的功能可以使用。 FuncFormatter
.
OldAutoLocator
¶
此股票代码已弃用。
必修的 , 被禁止的 和 允许 参数 cbook.normalize_kwargs
¶
这些参数已弃用。
这个 TTFPATH
和 AFMPATH
环境变量¶
支持(无文件) TTFPATH
和 AFMPATH
环境变量已弃用。其他字体可以使用 matplotlib.font_manager.fontManager.addfont()
.
matplotlib.compat
¶
此模块已弃用。
matplotlib.backends.qt_editor.formsubplottool
¶
此模块已弃用。使用 matplotlib.backends.backend_qt5.SubplotToolQt
相反。
AVConv动画编写器已弃用¶
这个 AVConvBase
, AVConvWriter
和 AVConvFileWriter
类,以及相关的 animation.avconv_path
和 animation.avconv_args
rcParams已弃用。
Debian8(2015年,下线06/2020)和Ubuntu14.04(下线04/2019)是Debian和UbuntuAvconv的最新版本。仍然可以通过使用基于ffmpeg的writers来强制使用avconv rcParams["animation.ffmpeg_path"]
(default: 'ffmpeg'
) 设置为“avconv”。
log/symlog scale base、ticks和nonpos规范¶
semilogx
, semilogy
, loglog
, LogScale
和 SymmetricalLogScale
用于获取依赖于轴方向的关键字参数(“basex”vs“basey”、“subsx”vs“subsy”、“nonposx”vs“nonposy”);这些参数名现在被弃用,取而代之的是“base”、“subs”、“nonpositive”。这种贬抑也会影响例如。 ax.set_yscale("log", basey=...)
现在必须拼出来 ax.set_yscale("log", base=...)
.
从“非正面”到“非正面”的变化也会影响 LogTransform
, InvertedLogTransform
, SymmetricalLogTransform
等。
使用 不同的 轴的x轴和y轴的基 loglog
绘图,例如。 ax.set_xscale("log", base=10); ax.set_yscale("log", base=2)
.
DraggableBase.artist_picker
¶
此方法已弃用。如果以前在子类中重新实现了它,请使用 Artist.set_picker
.
clear_temp 参数和属性 FileMovieWriter
¶
这个 clear_temp 参数和属性 FileMovieWriter
已弃用。将来,将文件放在临时目录中(使用 frame_prefix=None
,默认值)将被清除;放置在其他位置的文件将不会被清除。
不推荐使用的rcParams验证器¶
在中定义的以下验证器 rcsetup
,已弃用: validate_fontset
, validate_mathtext_default
, validate_alignment
, validate_svg_fontset
, validate_pgf_texsystem
, validate_movie_frame_fmt
, validate_axis_locator
, validate_movie_html_fmt
, validate_grid_axis
, validate_axes_titlelocation
, validate_toolbar
, validate_ps_papersize
, validate_legend_loc
, validate_bool_maybe_none
, validate_hinting
, validate_movie_writers
, validate_webagg_address
, validate_nseq_float
, validate_nseq_int
. 为了测试rcParam值是否可以接受,可以测试。 rc = RcParams(); rc[k] = v
引发异常。
更严格的rcParam验证¶
rcParams["axes.axisbelow"]
(default: 'line'
) “所有字符串”(当前不区分大小写)的选项。不赞成这样做;在将来的版本中,只支持精确的字符串“line”(区分大小写)。
add_subplot()
验证其输入¶
特别是 add_subplot(rows, cols, index)
,所有参数必须是整数。以前接受字符串和浮点数并将其转换为int。现在将发出弃用警告。
matplotlib.test(recursionlimit=...)
¶
这个 递归极限 参数 matplotlib.test
被贬低。
mathtext胶水¶
这个 copy 参数 mathtext.Glue
已弃用(底层的粘合规范现在是不可变的)。 mathtext.GlueSpec
被贬低。
签名 Artist.draw
和 Axes.draw
¶
这个 下部 参数到 Axes.draw
已弃用。使用 Axes.redraw_in_frame
相反。
没有通过考试 渲染器 参数到 Axes.draw
已弃用。使用 axes.draw_artist(axes)
相反。
These changes make the signature of the draw
(artist.draw(renderer)
)
method consistent across all artists; thus, additional parameters to
Artist.draw
are deprecated.
DraggableBase.on_motion_blit
¶
此方法已弃用。 DraggableBase.on_motion
现在处理闪电战和非闪电战。
将破折号偏移作为无传递¶
通过传递 (offset, (on-length, off-length, on-length, off-length, ...))
pair作为的linestyle属性 Line2D
和 LineCollection
. 以前,某些api会接受 offset = None
作为 offset = 0
,但这从未得到普遍实施,例如矢量输出。支持 offset = None
如果已弃用,请将偏移量改为0。
RendererCairo.fontweights
, RendererCairo.fontangles
¶
... 已弃用。
autofmt_xdate(which=None)
¶
这是不赞成的,使用更明确的同义词, which="major"
,而不是。
JPEG选项¶
这个 ** , 优化 和 进步的 关键字参数 savefig
只在保存为JPEG时使用的已弃用。 rcParams["savefig.jpeg_quality"]
(default: 95
) 同样不赞成。
这些选项现在应该直接传递给枕头使用 savefig(..., pil_kwargs={{"quality": ..., "optimize": ..., "progressive": ...}})
.
dviread.Encoding
¶
这个类(大部分)被破坏了,已经被弃用了。
轴和定位器 pan
和 zoom
¶
未使用的 pan
和 zoom
方法 Axis
和 Locator
已弃用。平移和缩放现在使用 start_pan
, drag_pan
和 end_pan
方法 Axes
.
将无传递到各个Axes子类工厂¶
传球支持 None
作为基类 axes.subplot_class_factory
, axes_grid1.parasite_axes.host_axes_class_factory
, axes_grid1.parasite_axes.host_subplot_class_factory
, axes_grid1.parasite_axes.parasite_axes_class_factory
和 axes_grid1.parasite_axes.parasite_axes_auxtrans_class_factory
已弃用。显式传递正确的基 Axes
改为类。
axes_rgb
¶
在 mpl_toolkits.axes_grid1.axes_rgb
, imshow_rgb
已弃用(使用 ax.imshow(np.dstack([r, g, b]))
取而代之的是); RGBAxesBase
已弃用(使用 RGBAxes
取而代之的是); RGBAxes.add_RGB_to_figure
已弃用(它是一个内部助手)。
Substitution.from_params
¶
此方法已弃用。如果需要,直接分配给 params
替换对象的属性。
set_factor
方法 mpl_toolkits.axisartist
定位器¶
这个 set_factor
方法 mpl_toolkits.axisartist
不推荐使用定位器(与“标准”Matplotlib记号定位器不同)。
widgets.SubplotTool
回调和轴¶
这个 funcleft
, funcright
, funcbottom
, functop
, funcwspace
和 funchspace
方法 widgets.SubplotTool
被贬低。
这个 axleft
, axright
, axbottom
, axtop
, axwspace
和 axhspace
属性 widgets.SubplotTool
已弃用。访问 ax
相应滑块的属性(如果需要)。
数学文本 Glue
帮助程序类¶
这个 Fil
, Fill
, Filll
, NegFil
, NegFill
, NegFilll
和 SsGlue
中的类 matplotlib.mathtext
模块已弃用。另一种方法是,直接使用 Glue("fil")
等。
FigureCanvasGTK3._renderer_init¶
不赞成重写此方法来初始化GTK3画布的呈现器。相反,渲染器应该在 __init__
子类的方法(该方法应调用基类的 __init__
视情况而定)。保持与Matplotlib早期版本的兼容性 必修的 _renderer_init
一个完全空的实现 (def _renderer_init(self): pass
)可能会保留,不会触发弃用警告。
中的路径辅助对象 bezier
¶
bezier.make_path_regular
已弃用。使用 Path.cleaned()
(或) Path.cleaned(curves=True)
,等等) STOP
路径末尾的代码)。
bezier.concatenate_paths
已弃用。使用 Path.make_compound_path()
相反。
animation.html_args
RCPARAM¶
未使用的 animation.html_args
rcParam和 animation.HTMLWriter.args_key
属性已弃用。
text.latex.preview
RCPARAM¶
此rcParam控制预览.sty不推荐使用LaTeX包来对齐TeX字符串基线,因为Matplotlib自己的dvi解析器现在也可以计算基线预览.sty.
SubplotSpec.get_rows_columns
¶
此方法已弃用。使用 GridSpec.nrows
, GridSpec.ncols
, SubplotSpec.rowspan
和 SubplotSpec.colspan
而不是属性。
基于Qt4的后端¶
不推荐使用qt4agg和qt4cairo后端。Qt4已于2015年结束使用,目前还没有发布最新版本的Python。请考虑切换到Qt5。
方块 和 少数的 参数 Axes.set_xticklabels
和 Axes.set_yticklabels
只会变成关键字¶
的所有参数 Figure.subplots
除了 诺尔斯 和 恩科斯 只会变成关键字¶
这样可以避免打字。 subplots(1, 1, 1)
什么意思 subplot(1, 1, 1)
,但实际上 subplots(1, 1, sharex=1)
.
RendererWx.get_gc
¶
此方法已弃用。访问 gc
改为直接属性。
add_all 参数在 axes_grid
¶
这个 add_all 参数 axes_grid1.axes_grid.Grid
, axes_grid1.axes_grid.ImageGrid
, axes_grid1.axes_rgb.make_rgb_axes
和 axes_grid1.axes_rgb.RGBAxes
已弃用。轴现在总是添加到父图形中,不过可以稍后使用 ax.remove()
.
BboxBase.inverse_transformed
¶
.BboxBase.inverse_transformed
已弃用(调用 BboxBase.transformed
上 inverted()
转换)。
方向 属于 eventplot()
和 EventCollection
¶
设置 方向 一个 eventplot()
或 EventCollection
不推荐使用“none”或“none”;请改为“horizontal”。此外,这两个方向(“水平”和“垂直”)将来将区分大小写。
少数的 克瓦格 Axis.get_ticklocs
只会变成关键字¶
不赞成按位置传递此参数。
不区分大小写的属性¶
将中的大写或混合大小写属性名规范化为小写 Artist.set
和 Artist.update
已弃用。将来,属性名将按原样传递,这样就可以传递 帕查 或 UVC .
ContourSet.ax
, Quiver.ax
¶
这些属性被弃用,取而代之的是 ContourSet.axes
和 Quiver.axes
,与其他艺术家保持一致。
Locator.refresh()
和相关方法¶
Locator.refresh()
已弃用。此方法在某些位置被调用,以让定位器更新其内部状态,通常基于轴限制。如果需要,定位器现在应该在调用时始终参考轴限制。
关联的助手方法 NavigationToolbar2.draw()
和 ToolViewsPositions.refresh_locators()
已弃用,应替换为对的调用 draw_idle()
在相应的画布上。
ScalarMappable
跳棋¶
这个 add_checker
和 check_update
方法和 update_dict
属性 ScalarMappable
被贬低。
pyplot.tight_layout
和 ColorbarBase
参数将成为关键字¶
的所有参数 pyplot.tight_layout
所有参数 ColorbarBase
除了第一个( ax )将成为关键字,与 Figure.tight_layout
和 Colorbar
,分别。
AxisArtist.dpi_transform
¶
... 已弃用。比例尺 Figure.dpi_scale_trans
以1/72达到同样的效果。
offset_position
property of Collection
¶
这个 offset_position
性质 Collection
已弃用。未来, Collection
s总是表现得好像 offset_position
设置为“屏幕”(默认值)。
传球支持 offset_position="data"
到 draw_path_collection
所有渲染器类中的一个已弃用。
transforms.AffineDeltaTransform
可用作替代品。这个API是实验性的,将来可能会改变。
testing.compare.make_external_conversion_command
¶
... 已弃用。
axes_grid1.CbarAxes
属性¶
这个 cbid
和 locator
属性已弃用。使用 mappable.colorbar_cid
和 colorbar.locator
,与标准色条一样。
qt_compat.is_pyqt5
¶
在预测PyQt6的未来版本时,不推荐使用此函数。Qt版本可以使用 QtCore.qVersion()
.
参数的重新排序 Artist.set
¶
在未来的版本中, Artist.set
将按给定的顺序应用艺术家属性。这只会影响 颜色 , 变色染料 , 脸色 ,以及 Collection
s, 阿尔法 属性:属性 颜色 属性现在需要首先传递,以便不重写其他属性。这与例如。 Artist.update
,它不会对传递给它的属性重新排序。
将多个键作为单个逗号分隔字符串或多个参数传递给 ToolManager.update_keymap
¶
这是不赞成的;而是作为字符串列表传递键。
Statusbar类和属性¶
这个 statusbar
属性 FigureManagerBase
, StatusbarBase
以及它的所有子类 StatusBarWx
,已弃用,因为消息现在显示在工具栏中。
ismath
parameter of draw_tex
¶
这个 ismath
的参数 draw_tex
所有呈现器类的方法都已弃用(作为对 draw_tex
--不可混淆 draw_text
! --意味着整个字符串应该传递给 usetex
机械)。同样,文本机器将不再通过 ismath
调用时的参数 draw_tex
(这应该只对后端实现者重要)。
经过 ismath="TeX!"
到 RendererAgg.get_text_width_height_descent
已弃用。通过 ismath="TeX"
相反,与其他支持True、False和“TeX”值的低级api保持一致 ismath
.
matplotlib.ttconv
¶
此模块已弃用。
PGF中更严格的PDF元数据密钥¶
使用PGF后端以PDF格式保存元数据目前将所有键规范化为小写,而PDF后端只接受规范大小写。这是不赞成的;在将来的版本中,只有PDF规范中列出的规范大小写键(以及 PdfPages
文件)将被接受。
Qt修改键¶
这个 MODIFIER_KEYS
, SUPER
, ALT
, CTRL
和 SHIFT
全局变量 matplotlib.backends.backend_qt4agg
, matplotlib.backends.backend_qt4cairo
, matplotlib.backends.backend_qt5agg
和 matplotlib.backends.backend_qt5cairo
模块已弃用。
TexManager
¶
这个 TexManager.serif
, TexManager.sans_serif
, TexManager.cursive
和 TexManager.monospace
属性已弃用。
移除¶
已删除以下已弃用的API:
模块¶
backends.qt_editor.formlayout
(改用PyPI上的formlayout模块)。
类、方法和属性¶
artist.Artist.aname
财产(不可替换)axis.Axis.iter_ticks
(无替换)- 支持不提供
backend_bases.GraphicsContextBase.set_hatch_color
方法 backend_bases.RendererBase.strip_math()
(使用)cbook.strip_math()
相反)backend_wx.debug_on_error()
(无替换)backend_wx.raise_msg_to_str()
(无替换)backend_wx.fake_stderr
(无替换)backend_wx.MenuButtonWx
(无替换)backend_wx.PrintoutWx
(无替换)_backend_tk.NavigationToolbar2Tk.set_active()
(无替换)backend_ps.PsBackendHelper.gs_exe
财产(不可替换)backend_ps.PsBackendHelper.gs_version
财产(不可替换)backend_ps.PsBackendHelper.supports_ps2write
财产(不可替换)backend_ps.RendererPS.afmfontd
财产(不可替换)backend_ps.GraphicsContextPS.shouldstroke
财产(不可替换)backend_gtk3.FileChooserDialog
(无替换)backend_gtk3.SaveFigureGTK3.get_filechooser()
(无替换)backend_gtk3.NavigationToolbar2GTK3.get_filechooser()
(无替换)backend_gtk3cairo.FigureManagerGTK3Cairo
(使用)backend_gtk3.FigureManagerGTK3
相反)backend_pdf.RendererPdf.afm_font_cache
财产(不可替换)backend_pgf.LatexManagerFactory
(无替换)backend_qt5.NavigationToolbar2QT.buttons
财产(不可替换)backend_qt5.NavigationToolbar2QT.adj_window
财产(不可替换)bezier.find_r_to_boundary_of_closedpath()
(无替换)cbook.dedent()
(使用)inspect.cleandoc
相反)cbook.get_label()
(无替换)cbook.is_hashable()
(使用)isinstance(..., collections.abc.Hashable)
相反)cbook.iterable()
(使用)numpy.iterable()
相反)cbook.safezip()
(无替换)colorbar.ColorbarBase.get_cmap
(使用)ScalarMappable.get_cmap
相反)colorbar.ColorbarBase.set_cmap
(使用)ScalarMappable.set_cmap
相反)colorbar.ColorbarBase.get_clim
(使用)ScalarMappable.get_clim
相反)colorbar.ColorbarBase.set_clim
(使用)ScalarMappable.set_clim
相反)colorbar.ColorbarBase.set_norm
(使用)ScalarMappable.set_norm
相反)dates.seconds()
(无替换)dates.minutes()
(无替换)dates.hours()
(无替换)dates.weeks()
(无替换)dates.strpdate2num
和dates.bytespdate2num
(使用)time.strptime
或dateutil.parser.parse
或dates.datestr2num
相反)docstring.Appender
(无替换)docstring.dedent()
(使用)inspect.getdoc
相反)docstring.copy_dedent()
(使用)docstring.copy()
和inspect.getdoc
相反)font_manager.OSXInstalledFonts()
(无替换)image.BboxImage.interp_at_native
财产(不可替换)lines.Line2D.verticalOffset
财产(不可替换)matplotlib.checkdep_dvipng
(无替换)matplotlib.checkdep_ghostscript
(无替换)matplotlib.checkdep_pdftops
(无替换)matplotlib.checkdep_inkscape
(无替换)matplotlib.get_py2exe_datafiles
(无替换)matplotlib.tk_window_focus
(使用)rcParams['tk.window_focus']
相反)mlab.demean()
(使用)mlab.detrend_mean()
相反)path.get_paths_extents()
(使用)path.get_path_collection_extents()
相反)path.Path.has_nonfinite()
(使用)not np.isfinite(self.vertices).all()
相反)projections.process_projection_requirements()
(无替换)pyplot.plotfile()
(而是使用pandas.read_csv
或numpy.loadtxt
或者类似的方法,并使用常规的pyplot函数来绘制加载的数据。)quiver.Quiver.color()
(使用)Quiver.get_facecolor()
相反)quiver.Quiver.keyvec
财产(不可替换)quiver.Quiver.keytext
财产(不可替换)rcsetup.validate_qt4()
(无替换)rcsetup.validate_qt5()
(无替换)rcsetup.validate_verbose()
(无替换)rcsetup.ValidateInterval
(无替换)scale.LogTransformBase
(使用)scale.LogTransform
相反)scale.InvertedLogTransformBase
(使用)scale.InvertedLogTransform
相反)scale.Log10Transform
(使用)scale.LogTransform
相反)scale.InvertedLog10Transform
(使用)scale.InvertedLogTransform
相反)scale.Log2Transform
(使用)scale.LogTransform
相反)scale.InvertedLog2Transform
(使用)scale.InvertedLogTransform
相反)scale.NaturalLogTransform
(使用)scale.LogTransform
相反)scale.InvertedNaturalLogTransform
(使用)scale.InvertedLogTransform
相反)scale.get_scale_docs()
(无替换)sphinxext.plot_directive.plot_directive()
(使用类)PlotDirective
相反)sphinxext.mathmpl.math_directive()
(使用类)MathDirective
相反)spines.Spine.is_frame_like()
(无替换)testing.decorators.switch_backend()
(使用)@pytest.mark.backend
装饰工)text.Text.is_math_text()
(使用)cbook.is_math_text()
相反)text.TextWithDash()
(使用)text.Annotation
相反)textpath.TextPath.is_math_text()
(使用)cbook.is_math_text()
相反)textpath.TextPath.text_get_vertices_codes()
(使用)textpath.text_to_path.get_text_path()
相反)textpath.TextToPath.glyph_to_path()
(使用)font.get_path()
以及手动平移顶点)ticker.OldScalarFormatter.pprint_val()
(无替换)ticker.ScalarFormatter.pprint_val()
(无替换)ticker.LogFormatter.pprint_val()
(无替换)ticker.decade_down()
(无替换)ticker.decade_up()
(无替换)Tick
性质gridOn
,tick1On
,tick2On
,label1On
,label2On
(使用)set_visible()
/get_visible()
在Tick.gridline
,Tick.tick1line
,Tick.tick2line
,Tick.label1
,Tick.label2
相反)widgets.SpanSelector.buttonDown
财产(不可替换)mplot3d.proj3d.line2d()
(无替换)mplot3d.proj3d.line2d_dist()
(无替换)mplot3d.proj3d.line2d_seg_dist()
(无替换)mplot3d.proj3d.mod()
(使用)numpy.linalg.norm
相反)mplot3d.proj3d.proj_transform_vec()
(无替换)mplot3d.proj3d.proj_transform_vec_clip()
(无替换)mplot3d.proj3d.vec_pad_ones()
(无替换)mplot3d.proj3d.proj_trans_clip_points()
(无替换)mplot3d.art3d.norm_angle()
(无替换)mplot3d.art3d.norm_text_angle()
(无替换)mplot3d.art3d.path_to_3d_segment()
(无替换)mplot3d.art3d.paths_to_3d_segments()
(无替换)mplot3d.art3d.path_to_3d_segment_with_codes()
(无替换)mplot3d.art3d.paths_to_3d_segments_with_codes()
(无替换)mplot3d.art3d.get_patch_verts()
(无替换)mplot3d.art3d.get_colors()
(无替换)mplot3d.art3d.zalpha()
(无替换)mplot3d.axis3d.get_flip_min_max()
(无替换)mplot3d.axis3d.Axis.get_tick_positions()
(无替换)axisartist.axis_artist.UnimplementedException
(无替换)axisartist.axislines.SimpleChainedObjects
(使用)axis_grid1.mpl_axes.SimpleChainedObjects
相反)axisartist.axislines.Axes.AxisDict
(使用)axis_grid1.mpl_axes.Axes.AxisDict
相反)
争论¶
Axes.text()
/pyplot.text()
不支持该参数withdash
不再。使用Axes.annotate()
和pyplot.annotate()
相反。- 的第一个参数
matplotlib.use
已从重命名arg
到backend
(只有通过关键字传递时才相关)。 - 参数
warn
属于matplotlib.use
已删除。如果无法切换后端,将始终引发ImportError
如果force
已设置;如果需要,请捕获该错误。 - 的所有参数
matplotlib.use
除了第一个现在是关键字。 - 未使用的参数
shape
和imlim
属于imshow()
现在已删除。所有参数超出extent
现在只显示关键字。 - 未使用的参数
interp_at_native
属于BboxImage
已删除。 - 参数
usetex
属于TextToPath.get_text_path
已删除。使用ismath='TeX'
相反。 - 参数
block
属于show()
现在仅为关键字,不再接受任意参数或关键字参数。 - 参数
frameon
属于Figure.savefig
已删除。使用facecolor="none"
以获得透明的背景。 - 通过A
wx.EvtHandler
作为第一个论点backend_wx.TimerWx
不再支持;的签名TimerWx
现在符合TimerBase
. - 这个
manage_xticks
参数boxplot
和bxp
已重命名为manage_ticks
. - 这个
normed
参数hist2d
已重命名为density
. - 这个
s
参数Annotation
已重命名为text
. - 对于中的所有函数
bezier
支持一个tolerence
参数,此参数已重命名为tolerance
. axis("normal")
不再支持。使用等效的axis("auto")
相反。axis()
不再接受任意关键字参数。Axis.set_ticklabels()
不接受除ticklabels
.mpl_toolkits.mplot3d.art3d.Poly3DCollection.set_zsort
不接受该值True
不再。而是传递等效值“average”。AnchoredText
不再接受horizontalalignment
或verticalalignment
关键字参数。ConnectionPatch
不再接受arrow_transmuter
和connector
关键字参数,自3.0以来没有任何作用。FancyArrowPatch
不再接受arrow_transmuter
和connector
关键字参数,自3.0以来没有任何作用。TextPath
不再接受任意位置或关键字参数。MaxNLocator.set_params()
不再接受任意关键字参数。pie
不再接受和压缩非1D输入;将1D输入传递给x
争论。- 将(n,1)形错误数组传递给
Axes.errorbar()
不再支持;改为传递1D数组。
RCPARAMS¶
- 这个
text.latex.unicode
rcParam已被删除,没有替换。Matplotlib现在在usetex中始终支持unicode。 - 这个
savefig.frameon
rcParam已被删除。套rcParams["savefig.facecolor"]
(default:'auto'
) 设置为“无”以获得透明背景。 - 这个
pgf.debug
,verbose.fileo
和verbose.verbose.level
rcParams无效,已被删除。 - 设置支持
rcParams["mathtext.default"]
(default:'it'
) “带圆圈”已删除。
环境变量¶
MATPLOTLIBDATA
(不可更换)。
数学文本¶
- 这个
\stackrel
命令(其行为与其LaTeX版本不同)已被删除。使用\genfrac
相反。 - 这个
\mathcircled
命令已被删除。直接使用Unicode字符,例如'\N{{CIRCLED LATIN CAPITAL LETTER A}}'
,而不是。