ax1=fig1.add_subplot(111)
を定義し、関連するlabel
の値を持つ8つのデータ系列をプロットした後、次のコード行を使用して凡例を追加しました。Pyplotの凡例インデックスエラー:タプルインデックスが範囲外
ax1.legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
私は問題なく何度も前にこのメソッドを使用しているが、この機会に、それは私がなぜこれが起こっている見当がつかない本当に提案をいただければ幸いですIndexError: tuple index out of range
Traceback (most recent call last):
File "interface_tension_adhesion_plotter.py", line 45, in <module>
ax1.legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/axes/_axes.py", line 564, in legend
self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/legend.py", line 386, in __init__
self._init_legend_box(handles, labels, markerfirst)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/legend.py", line 655, in _init_legend_box
fontsize, handlebox))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/legend_handler.py", line 119, in legend_artist
fontsize, handlebox.get_transform())
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/legend_handler.py", line 476, in create_artists
self.update_prop(coll, barlinecols[0], legend)
IndexError: tuple index out of range
というエラーを生成します。
これはエラーバーのプロットに関連しているようです。しかし、あなたを助けるためには、[mcve]を提供する必要があります。 – ImportanceOfBeingErnest
これは確かにエラーバーでプロットされています: 'ax1.errorbar(tensionsarray、meanproportionsarray、yerr = stdproportionsarray、label =" adhsion = {:02.1f} "フォーマット(l))' – crevell
これは[mcve]ではありません。詳しい情報を提供したい場合は、[編集]をクリックしてください。 – ImportanceOfBeingErnest