J'ai écrit un code simple pour former Taylor Digram à l'aide du logiciel skillmetrics. J'ai utilisé la version Python Python 2.7.12. Le code est comme suit:-
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()
Mais, cela me donne une erreur. L’erreur est la suivante: -
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'
La fonction to_rgb
a été ajoutée relativement récemment à l'espace de noms matplotlib.colors
. Vous avez probablement une ancienne version de matplotlib installée. Essayez de mettre à jour la dernière version de matplotlib.
Cela est lié aux versions des deux bibliothèques d'outils pour lesquelles ipykernel et matplotlib ne sont pas compatibles. AttributeError: l'objet 'module' n'a pas d'attribut 'to_rgba'
$ Sudo pip install --upgrade matplotlib