0
繪製ylabel我需要繪製多指標數據框從列0級ylabels。數據幀如下:如何大熊貓多指標數據幀
PCs pc1 pc2 pc3 \
explained_variance_ratio 9.977643e-01 2.196399e-03 3.275875e-05
wavelength
540.00 0.015110 -0.004772 -0.018467
540.05 0.015110 -0.004772 -0.018467
540.10 0.015110 -0.004772 -0.018467
540.15 0.015110 -0.004772 -0.018467
540.20 0.015110 -0.004772 -0.018467
540.25 0.015110 -0.004772 -0.018467
540.30 0.015110 -0.004772 -0.018467
540.35 0.015110 -0.004772 -0.018467
540.40 0.015081 -0.004226 -0.017577
540.45 0.015081 -0.004226 -0.017577
.......
ylabel應該是pc1,pc2,pc3 ....帶波長的xlabel。
我曾嘗試以下不工作:
pca_df.plot(subplots=True, sharex=True, title='Principle Components', \
legend=False, y=list(pca_df.columns.levels[0]))
錯誤是:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/usr/lib/python2.7/dist-packages/pandas/tools/plotting.py", line 1716, in plot_frame
ser = frame[y]
File "/usr/lib/python2.7/dist-packages/pandas/core/frame.py", line 1652, in __getitem__
return self._getitem_array(key)
File "/usr/lib/python2.7/dist-packages/pandas/core/frame.py", line 1697, in _getitem_array
return self.take(indexer, axis=1, convert=True)
File "/usr/lib/python2.7/dist-packages/pandas/core/generic.py", line 1166, in take
indices, len(self._get_axis(axis)))
File "/usr/lib/python2.7/dist-packages/pandas/core/indexing.py", line 1438, in _maybe_convert_indices
if mask.any():
AttributeError: 'bool' object has no attribute 'any'
也試過:
pca_df.plot(subplots=True, sharex=True, title='Principle Components', \
legend=False)
plt.ylabel(pca_df.columns.levels[0])
雖然繪製覆蓋所有ylabel情節很簡單:
Index([u'pc1', u'pc10', u'pc2', u'pc3', u'pc4', u'pc5', u'pc6', u'pc7', u'pc8', u'pc9'], dtype='object')