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
706 stars 38 forks source link

Location of the dashed box to move the subplot is shifted from the original subplots #66

Open shizkaz opened 7 months ago

shizkaz commented 7 months ago

Dear rgerum,

First of all, I really appreciate your code, pylustrator, which is really helpful to make figures, especially for academic quality publication. Although the module is really nice, but I found small bug as attached, where location of the dashed box to move the subplot is shifted from the original subplots. In this case, I clicked the left figure but the box is shifted and its size is also different from the original size. My environment is OS: Mac OSX 14.3 (Sonoma) Python 3.11.7 (with matplotlib==3.6.2), which is installed by pip or Python 3.11.5 (with matplotlib==3.8.0), which is installed by conda Both cases were failed.

Again thank you for your nice app, shiz

スクリーンショット 2024-01-31 13 49 44
rgerum commented 7 months ago

could you give me a minimal example of how to reproduce the bug? E.g. some code that opens the figure with this problem. Sometimes something like this occurs when you have something selected and resize the window but it should disappear when you change the selection. But maybe something with your figure transformations is off and then it might depend on particularities of your figure, hence the minimal example might help me find the problem.

shizkaz commented 7 months ago

Thank you for your response. The above bug can be reproduced with your example code, i.e. as follows. The attached is the screen shot with this code.

スクリーンショット 2024-02-07 11 45 53

# import matplotlib and numpy as usual
import matplotlib.pyplot as plt
import numpy as np

# now import pylustrator
import pylustrator

# activate pylustrator
pylustrator.start()

# build plots as you normally would
np.random.seed(1)
t = np.arange(0.0, 2, 0.001)
y = 2 * np.sin(np.pi * t)
a, b = np.random.normal(loc=(5., 3.), scale=(2., 4.), size=(100,2)).T
b += a

plt.figure(1)
plt.subplot(131)
plt.plot(t, y)

plt.subplot(132)
plt.plot(a, b, "o")

plt.subplot(133)
plt.bar(0, np.mean(a))
plt.bar(1, np.mean(b))
plt.show()