I would like to plot on top of a picture of a graph from a paper. I plot the picture with a simple imshow:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('screenshot.png')
plt.imshow(img)
Now, is there a way to align the axes so that I can plot my own data of the electron density and compare with the data in the figure? I tried to use a scaling factor as suggested by Chat GPT, but I can't make it work. Here is what it suggested:
# Data point in the picture
x_picture = 0.01
# Corresponding data point on the Python plot
x_python_plot = 80
# Calculate the scaling factor
scaling_factor = x_python_plot / x_picture
# Apply the scaling factor to your data for plotting
x_data_scaled = [x * scaling_factor for x in x_data]
# Plot your data on the new axes
ax.plot(x_data_scaled, y_data, color='red', linewidth=2)
(and the same for y, but for x alone it already doesn't work). I think plt.imshow(img, extent=[x1, x2, y1, y2]) could work if I could determine the x's and y's somehow, but even then, there's the issue of the log scale on the x-axis. I know I could crop the image so the axes coincide with the axes of the plot, but I would rather not do it like that and keep the layout of the figure.
Your ideas are appreciated!
Below are the picture loaded with imshow and the raw picture if you want to try it out.