Open AyanS13 opened 1 day ago
Hi Ayan,
Which OS, Python version and HCIpy version are you using? Also could you please provide a MRE?
I ran the following code on my system (NixOS, linux x86_64) using a freshly installed HCIpy 0.6.0 on Python 3.11.9:
from hcipy import *
from matplotlib import pyplot as plt
vlt_aperture = make_vlt_aperture()
grid = make_pupil_grid(128, diameter=10)
aperture = vlt_aperture(grid)
imshow_field(aperture, cmap='gray', interpolation='nearest')
plt.plot(grid.x, grid.y, '.')
plt.xlabel('x [m]')
plt.ylabel('y [m]')
plt.xlim(2.5, 4.5)
plt.ylim(-0.85, 0.85)
plt.show()
The output is as presented in the tutorial Telescope pupils and Grids.
I suspect it will either be something with your versioning or mabye you changed something in the matplotlib rc_params and didnt change it back?
Hope it helps, let me know if it doesn't Cheers, Tom
Hi Tom, Thanks a lot for responding. I am using the latest 0.6.0 version of hcipy and Python 3.9.6 on MacOS. I also checked if I have altered matplotlib rc_params somehow. I did not find any. Still, I reverted them back to the defaults. But the output remains the same with that large amount of white space.
P.S. I copy pasted the code snippet you shared in VS Code.
Can you also give me your matplotlib version? Ill try to run your versions on my machine to see if I can recreate the behaviour.
I use Windows 10, python 3.10.14, matplotlib 3.8.4 and the latest hcipy master branch version. On my machine everything works as it should. Are you running this in a Jupyter notebook? I know that the plotting inside the notebook cells does not work well with the xlim and ylim settings. Do you have the same problem if you run the code either in an iPython terminal or through a python script?
I can reproduce the error in a Jupyter notebook on my side. This does not happen if I run the code in an iPython terminal or through a python script.
Can you also give me your matplotlib version? Ill try to run your versions on my machine to see if I can recreate the behaviour.
I use matplotlib 3.9.2
I can reproduce the error in a Jupyter notebook on my side. This does not happen if I run the code in an iPython terminal or through a python script.
I see, I tried to run it as a .py file rather than .ipynb in vs code itself, but the problem persisted. I will try with Python terminal and see. Do you have any guess, why xlim and ylim creates problem in jupyter notebook for imshow_field ?
I am not sure. I think what happens with the particular plotting code is that it creates the full figure in full size, and then only plots the area corresponding to the limits that you give to xlim and ylim. And then it add the axes around it. If you move the limits you can actually also move the figure around. It's a bit of a weird bug.
Yes, I'm aware of this bug. It has to do with Jupyter notebooks switching the bounding box of figures to "tight" by default. You can revert to the original matplotlib behavior by putting the following as the first cell of your notebook.
%matplotlib inline
%config InlineBackend.print_figure_kwargs = {'bbox_inches': None}
Hi hcipy team, Thanks a lot for this amazing package.
I was looking at the tutorials, specifically "Telescope Pupils and Grids". When I implement the part of code that zooms into the spider to show pixelation, the xlim and ylim are behaving in a rather odd way. Below I have attached this. I have cross-checked if the issue is with Python but found that it works well with normal plt.imshow