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
707 stars 37 forks source link

Prevents relative import of data to plot #64

Closed thensel23 closed 11 months ago

thensel23 commented 1 year ago

https://github.com/rgerum/pylustrator/blob/cf5a9663124f795c85eff6c5380f366faeeb3b09/pylustrator/helper_functions.py#L214

Changing the filename etc doesn't allow for relative imports of data to plot in the figure. The script then searches for data relative to the composing script, but not the original figure.py.

rgerum commented 1 year ago

I am not sure I completely understand your use case. You have a sub_folder/sub_figure.py that loads data relative to itself (e.g. sub_folder/data.npy). Then you want to include this in a main figure main_folder/main_figure.py. So I guess the data should be searched in sub_folder/data.npy thats why the code switches temporarily to the sub_folder directory. What is the part that goes wrong here? What other directory should it switch to?

thensel23 commented 11 months ago

Was a problem with my code and calling the script via a subprocess, sorry for the confusion.