简体   繁体   English

无法获取绘图 /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:3: MatplotlibDeprecationWarning:

[英]Unable to get plot /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:3: MatplotlibDeprecationWarning:

        date    high    low     close   Central      Bottom Top_Central Resistance_1    Support_1   Central_SMA Bottom_Central_SMA  Top_Central_SMA
1   2010-01-05  142.45  136.00  141.85  140.100000  139.225 140.975000      NaN       NaN          NaN  NaN NaN
2   2010-01-06  142.70  140.40  141.00  141.366667  141.550 141.183333  143.266667  138.891667  140.733333  140.3875    141.079167
3   2010-01-07  142.65  140.05  141.60  141.433333  141.350 141.516667  142.575000  140.125000  141.400000  141.4500    141.350000
4   2010-01-08  142.40  139.85  141.90  141.383333  141.125 141.641667  142.866667  140.291667  141.408333  141.2375    141.579167
5   2010-01-11  146.00  141.95  145.35  144.433333  143.975 144.891667  144.916667  141.616667  142.908333  142.5500    143.266667

Above dataframe is pivot DataFrame in my code.上面的数据框是我的代码中的枢轴数据框。

import matplotlib.dates as mdates
from matplotlib.dates import date2num
import matplotlib.pyplot as plt
Graph=pivot.copy()# Make a copy of pivot
try:
    Graph.reset_index(inplace=True)
    Graph['date'] = Graph['date'].apply(date2num)
except:
    pass
fig= plt.figure()
ax1= fig.add_subplot(111)
ax2= fig.add_subplot(111)
ax3= fig.add_subplot(111)

ax1.xaxis_date()
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%d-%m-%Y'))
ax2.plot(Graph.date, Graph['Resistance_1'], label='R1')
ax3.plot(Graph.date, Graph['Support_1'], label='S1')

plt.show()

When I run the above code I get the following error.当我运行上面的代码时,出现以下错误。

/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:3: MatplotlibDeprecationWarning: /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:3: MatplotlibDeprecationWarning:

Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.使用与先前轴相同的参数添加轴当前会重用较早的实例。 In a future version, a new instance will always be created and returned.在未来的版本中,将始终创建并返回一个新实例。 Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.同时,通过将唯一标签传递给每个轴实例,可以抑制此警告并确保未来的行为。

/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:4: MatplotlibDeprecationWarning: /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:4: MatplotlibDeprecationWarning:

Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.使用与先前轴相同的参数添加轴当前会重用较早的实例。 In a future version, a new instance will always be created and returned.在未来的版本中,将始终创建并返回一个新实例。 Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.同时,通过将唯一标签传递给每个轴实例,可以抑制此警告并确保未来的行为。

How to resolve this issue ?如何解决这个问题?

Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.使用与先前轴相同的参数添加轴当前会重用较早的实例。

The same argument that is meant here is "111":此处所指的相同参数是“111”:

ax2= fig.add_subplot(111)
ax3= fig.add_subplot(111)

The behavior is specified in the warning message: it doesn't add a new figure, it reuses the old one.该行为在警告消息中指定:它不会添加新图形,而是重用旧图形。 So you only have 1 figure even though you probably want to specify 3. I assume you need to look up the syntax of subplot and are mistaking it for something that it is not.因此,即使您可能想要指定 3,您也只有 1 个数字。我假设您需要查找 subplot 的语法,并将其误认为不是。 One correct way to use this would be:使用它的一种正确方法是:

ax1= fig.add_subplot(131)
ax2= fig.add_subplot(132)
ax2.plot(a,b)
ax3= fig.add_subplot(133)
ax3.plot(b,a)

You can also use 31X if you rather want 3 rows of images.如果您想要 3 行图像,也可以使用 31X。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 /usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43:未来警告: - /usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: OSError:[Errno 2]没有这样的文件或目录:'/usr/local/lib/python2.7/dist-packages/pyduino-0.0.0-py2.7.egg' - OSError: [Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/pyduino-0.0.0-py2.7.egg' ImportError:无法从“变压器”(/usr/local/lib/python3.7/dist-packages/transformers/__init__.py)导入名称“BigBirdTokenizer” - ImportError: cannot import name 'BigBirdTokenizer' from 'transformers' (/usr/local/lib/python3.7/dist-packages/transformers/__init__.py) PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/grpc/__init__.py' - PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/grpc/__init__.py' pip将2.7个软件包安装到/usr/local/lib/python3.2/dist-packages中 - pip installs 2.7 packages into /usr/local/lib/python3.2/dist-packages 如何从/usr/lib/python2.7/dist-packages/中的dir获取源软件包 - How to get source packages from dir in /usr/lib/python2.7/dist-packages/ 为什么 pip install 模块在 /usr/local/lib/python3.4/dist-packages - why pip install module in /usr/local/lib/python3.4/dist-packages 如何在appengine app中使用/usr/local/lib/python2.7/dist-packages中的模块 - How to use module from /usr/local/lib/python2.7/dist-packages in appengine app /usr/local/lib/python2.6/dist-packages/joblib/parallel.py:40:UserWarning:[Errno 30]只读文件系统。 joblib将以串行模式运行 - /usr/local/lib/python2.6/dist-packages/joblib/parallel.py:40: UserWarning: [Errno 30] Read-only file system. joblib will operate in serial mode ImportError:无法从“utils”(/usr/local/lib/python3.7/dist-packages/utils/__init__.py)导入名称“translate_sentence” - ImportError: cannot import name 'translate_sentence' from 'utils' (/usr/local/lib/python3.7/dist-packages/utils/__init__.py)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM