MatplotlibDeprecationWarning:tick1On 函数在 Matplotlib 3.1 中已弃用,将在 3.3 中删除
MatplotlibDeprecationWarning: The tick1On function was deprecated in Matplotlib 3.1 and will be removed in 3.3
如何在 matplotlib 中更新折旧的 tick1On
和 tick2On
?
# Turn off all the ticks
for t in ax.xaxis.get_major_ticks():
t.tick1On = False
t.tick2On = False
for t in ax.yaxis.get_major_ticks():
t.tick1On = False
t.tick2On = False
警告
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:151: MatplotlibDeprecationWarning:
The tick1On function was deprecated in Matplotlib 3.1 and will be removed in 3.3. Use Tick.tick1line.set_visible instead.
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:152: MatplotlibDeprecationWarning:
The tick2On function was deprecated in Matplotlib 3.1 and will be removed in 3.3. Use Tick.tick2line.set_visible instead.
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:154: MatplotlibDeprecationWarning:
The tick1On function was deprecated in Matplotlib 3.1 and will be removed in 3.3. Use Tick.tick1line.set_visible instead.
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:155: MatplotlibDeprecationWarning:
The tick2On function was deprecated in Matplotlib 3.1 and will be removed in 3.3. Use Tick.tick2line.set_visible instead.
根据抛出错误的警告更新代码
# Turn off all the ticks
for t in ax.xaxis.get_major_ticks():
t.Tick.tick1line.set_visible = False
t.Tick.tick2line.set_visible = False
for t in ax.yaxis.get_major_ticks():
t.Tick.tick1line.set_visible = False
t.Tick.tick2line.set_visible = False
<ipython-input-5-674bddf7d454> in pretty_plot_confusion_matrix(df_cm, annot, cmap, fmt, fz, lw, cbar, figsize, show_null_values, pred_val_axis)
149 # Turn off all the ticks
150 for t in ax.xaxis.get_major_ticks():
--> 151 t.Tick.tick1line.set_visible = False
152 t.Tick.tick2line.set_visible = False
153 for t in ax.yaxis.get_major_ticks():
AttributeError: 'XTick' object has no attribute 'Tick'
我可以使用
隐藏这些折旧警告
import warnings
warnings.filterwarnings("ignore", category=UserWarning)
但我想用最新的兼容性更新它。完整的代码可以在这里找到 confusion_matrix_pretty_print.py
我认为错误消息意味着您可以这样替换:
for t in ax.xaxis.get_major_ticks():
t.tick1line.set_visible(False)
t.tick2line.set_visible(False)
如何在 matplotlib 中更新折旧的 tick1On
和 tick2On
?
# Turn off all the ticks
for t in ax.xaxis.get_major_ticks():
t.tick1On = False
t.tick2On = False
for t in ax.yaxis.get_major_ticks():
t.tick1On = False
t.tick2On = False
警告
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:151: MatplotlibDeprecationWarning:
The tick1On function was deprecated in Matplotlib 3.1 and will be removed in 3.3. Use Tick.tick1line.set_visible instead.
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:152: MatplotlibDeprecationWarning:
The tick2On function was deprecated in Matplotlib 3.1 and will be removed in 3.3. Use Tick.tick2line.set_visible instead.
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:154: MatplotlibDeprecationWarning:
The tick1On function was deprecated in Matplotlib 3.1 and will be removed in 3.3. Use Tick.tick1line.set_visible instead.
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:155: MatplotlibDeprecationWarning:
The tick2On function was deprecated in Matplotlib 3.1 and will be removed in 3.3. Use Tick.tick2line.set_visible instead.
根据抛出错误的警告更新代码
# Turn off all the ticks
for t in ax.xaxis.get_major_ticks():
t.Tick.tick1line.set_visible = False
t.Tick.tick2line.set_visible = False
for t in ax.yaxis.get_major_ticks():
t.Tick.tick1line.set_visible = False
t.Tick.tick2line.set_visible = False
<ipython-input-5-674bddf7d454> in pretty_plot_confusion_matrix(df_cm, annot, cmap, fmt, fz, lw, cbar, figsize, show_null_values, pred_val_axis)
149 # Turn off all the ticks
150 for t in ax.xaxis.get_major_ticks():
--> 151 t.Tick.tick1line.set_visible = False
152 t.Tick.tick2line.set_visible = False
153 for t in ax.yaxis.get_major_ticks():
AttributeError: 'XTick' object has no attribute 'Tick'
我可以使用
隐藏这些折旧警告import warnings
warnings.filterwarnings("ignore", category=UserWarning)
但我想用最新的兼容性更新它。完整的代码可以在这里找到 confusion_matrix_pretty_print.py
我认为错误消息意味着您可以这样替换:
for t in ax.xaxis.get_major_ticks():
t.tick1line.set_visible(False)
t.tick2line.set_visible(False)