gpt4 book ai didi

python - 属性错误 : 'module' object has no attribute 'to_rgb'

转载 作者:太空狗 更新时间:2023-10-30 01:56:52 24 4
gpt4 key购买 nike

我使用 skillmetrics 包编写了一个简单的代码来形成泰勒图。我使用 python 版本 Python 2.7.12。代码如下:-

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import skill_metrics as sm
fire=pd.read_csv('fire.csv')
PMfire = zip(fire['Date'],fire['PM_fire'],fire['Embassy_PM'])
#taylor_stats1 = sm.taylor_statistics('PM_fire','Embassy_PM','Date')
o= {"Data":fire['Embassy_PM'],'Date':fire['Date']}# form date and and embassy datas
p= {"Data":fire['PM_fire'],'Date':fire['Date']}# form dictionary containg pm_fire and date
# Calculate statistics for Taylor diagram
# The first array element corresponds to the reference series
# for the while the second is that for the predicted series.
taylor_stats1 = sm.taylor_statistics(p,o,'Data')
sdev = np.array([taylor_stats1['sdev'][0]])# Calculate standard deviation
crmsd = np.array([taylor_stats1['crmsd'][0]])#Calculate root mean square difference
ccoef = np.array([taylor_stats1['ccoef'][0]])# Calculate correlation coefficient
sm.taylor_diagram(sdev,crmsd,ccoef)#form taylor digram
plt.savefig('taylor.png')
plt.show()

但是,它给我错误。错误如下:-

  File "<ipython-input-2-edf3b67792d8>", line 1, in <module>
runfile('/home/mala/Downloads/F/taylor_plot.py', wdir='/home/mala/Downloads/F')

File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
execfile(filename, namespace)

File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
builtins.execfile(filename, *where)

File "/home/mala/Downloads/F/taylor_plot.py", line 21, in <module>
sm.taylor_diagram(sdev,crmsd,ccoef)

File "/usr/local/lib/python2.7/dist-packages/skill_metrics/taylor_diagram.py", line 110, in taylor_diagram
plot_pattern_diagram_markers(X,Y,option)

File "/usr/local/lib/python2.7/dist-packages/skill_metrics/plot_pattern_diagram_markers.py", line 104, in plot_pattern_diagram_markers
rgba = clr.to_rgb(option['markercolor']) + (alpha,)

AttributeError: 'module' object has no attribute 'to_rgb'

最佳答案

to_rgb 函数是最近添加到 matplotlib.colors 命名空间中的。您可能安装了旧版本的 matplotlib。尝试更新到最新版本的 matplotlib。

关于python - 属性错误 : 'module' object has no attribute 'to_rgb' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47492556/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com