rgerum / pylustrator

Visualisations of data are at the core of every publication of scientific research results. They have to be as clear as possible to facilitate the communication of research. As data can have different formats and shapes, the visualisations often have to be adapted to reflect the data as well as possible. We developed Pylustrator, an interface to directly edit python generated matplotlib graphs to finalize them for publication. Therefore, subplots can be resized and dragged around by the mouse, text and annotations can be added. The changes can be saved to the initial plot file as python code.
GNU General Public License v3.0
708 stars 37 forks source link

More than 10 text elements results in IndexError #1

Closed christophmark closed 5 years ago

christophmark commented 5 years ago

With more than 10 text elements, pylustrator puts these text elements in the wrong order:

...
fig.text(0.5, 0.5, 'New Text', transform=fig.transFigure)  # id=fig.texts[0].new
fig.texts[0].set_text("A")
fig.texts[0].set_fontsize(12)
fig.texts[0].set_weight("bold")
fig.texts[0].set_position([0.090644, 0.886957])
fig.text(0.5, 0.5, 'New Text', transform=fig.transFigure)  # id=fig.texts[10].new
fig.texts[10].set_text("**")
fig.texts[10].set_weight("bold")
fig.texts[10].set_fontsize(9)
fig.texts[10].set_position([0.914611, 0.469000])
...

Because texts[10] is accessed before it is created, this results in an index error:

IndexError: list index out of range