我有一些代码在我的本地机器上使用Python3.7很好地工作,但是在远程服务器上使用Python3.7也会失败。奇怪的是,失败的错误是AttributeError: 'AxesSubplot' object has no attribute 'sharex'。然而,AxesSubplot应该有一个sharex作为属性,所以我不知道它从何而来。为了进行调试,下面是在我的远程服务器上不能工作的一段非常短的代码:
import numpy as np ; import matplotlib.pyplot as plt
x=np.arange(50) ; y = x
title='test'
plt.close(title)
fig=plt.figure(title, clear=True)
fig.suptitle(title)
ax1,ax2=fig.subplots(nrows=2)
ax1.sharex(ax2)你知道问题的根源是什么吗?
发布于 2022-04-21 06:11:08
发布于 2022-04-20 09:31:08
我认为这个错误来自于这一行:
fig=plt.figure(title, clear=True)删除clear=True位,然后重试。
https://stackoverflow.com/questions/71937207
复制相似问题