我正在使用pydiffusion模块绘制与扩散有关的图。我试图运行以下代码,但出现了该主题中提到的错误。 我在Google的帮助下添加了“ 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**