python - AttributeError:“Legend”对象没有“可拖动”属性
问题描述
我正在使用 pydiffusion 模块来绘制与扩散相关的图。我尝试运行以下代码,但我收到了主题中提到的错误。我在谷歌的帮助下添加了 'draggable()' 但无济于事。我没有太多的pydiffusion资源 请给我你的意见。谢谢你。这是代码
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from pydiffusion.core import DiffSystem
from pydiffusion.utils import step, mesh
from pydiffusion.simulation import mphSim
from pydiffusion.plot import profileplot, DCplot
diffsys = DiffSystem(Xr=[0, 1], X=[0, 1], DC=[1e-14, 1e-14], name='Constant D')
dis = mesh(0, 1000, 501)
profile_init = step(dis, 500, diffsys, name='Intitial step profile')
fig = plt.figure(figsize=(16, 6))
ax1, ax2 = fig.add_subplot(121), fig.add_subplot(122)
ax1.set_title('Diffusion Coefficients', fontsize=15)
ax2.set_title('Initial Step Profile', fontsize=15)
DCplot(diffsys, ax1)
profileplot(profile_init, ax2)
输出
网格化完成。网格最小值=2.000,最大值=2.000
AttributeError Traceback (most recent call last)
<ipython-input-37-6c67cfa7613d> in <module>
6 ax1.set_title('Diffusion Coefficients', fontsize=15)
7 ax2.set_title('Initial Step Profile', fontsize=15)
----> 8 DCplot(diffsys, ax1)
9 profileplot(profile_init, ax2)
~\Anaconda3\lib\site-packages\pydiffusion\plot.py in DCplot(diffsys, ax, err, **kwargs)
206 leg = ax.legend(numpoints=1, fontsize=leg_fontsize)
207 leg.get_frame().set_linewidth(0.0)
--> 208 leg.draggable()
209 plt.tight_layout()
210
AttributeError: 'Legend' object has no attribute 'draggable' ```
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
end of the error
**Below are the 'obtained plot' and 'expected plot'
[![obtained][1]][1]
[![Expected][2]][2]
[1]: https://i.stack.imgur.com/hkzMg.png
[2]: https://i.stack.imgur.com/7QRMU.png**
解决方案
推荐阅读
- kubernetes - 主节点中的 kubelet 和 dockerd 进程使用太多内存
- python - 在Python中存储位图中黑色像素的(x,y)坐标
- javascript - 如何在 React 中获取当前的 onChange 值?
- php - 如何防止对象泄露有关其自身的所有信息?(就像C的朋友)
- asp.net-mvc - SignalR Clients.Caller(Clients.Caller.GroupName) 不起作用
- php - 使用 static::MY_CONST vs self::MY_CONST vs SomeClass::MY_CONST 引用 PHP 7 中的常量
- amazon - 是否可以创建一个自定义技能来阻止 Echo dot 上的所有技能并仅使用密码解锁?
- php - 表中的多行数据到 JSON 数组
- angular - 除非安装 Redux Devtools,否则 ngrx Angular 应用程序无法运行
- python - 函数内部的类初始化?