小编cre*_*ell的帖子

Pyplot 图例索引错误:元组索引超出范围

在定义ax1=fig1.add_subplot(111)并绘制 8 个数据系列及其关联label值后,我使用以下代码行添加图例。

ax1.legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
Run Code Online (Sandbox Code Playgroud)

我以前曾多次使用过此方法,没有出现任何问题,但这次它会产生错误: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: …
Run Code Online (Sandbox Code Playgroud)

python matplotlib

3
推荐指数
1
解决办法
4338
查看次数

朱莉娅@threads single

Julia Threads 中是否有类似于singleOpenMP 中命令的东西,可以确保所有线程在特定代码块之前等待,然后仅在一个线程中执行该块?我有一个循环,它在一次对所有位置执行更新之前在线程之间分配力的计算,并且我找不到任何功能来在不终止循环的情况下实现此目的@threads

multithreading julia

2
推荐指数
1
解决办法
851
查看次数

标签 统计

julia ×1

matplotlib ×1

multithreading ×1

python ×1