dccsillag / magma-nvim

Interact with Jupyter from NeoVim.
GNU General Public License v3.0
988 stars 50 forks source link

[Bug] Matplotlib showing very large images #28

Open Josiah-tan opened 2 years ago

Josiah-tan commented 2 years ago

Describe the bug When I run code to show a matplotlib plot, the output image becomes larger after I do zt (to move the code up)

Expected behavior In the GIF (given in the readme of the repository) , the output plot appears to be the same in size when scrolling, Is this some option that I set in my config?

Screenshots If applicable, add screenshots to help explain your problem.

Before scrolling up: image After scrolling up: image Checkhealth: image neovim version/ build: image

dccsillag commented 2 years ago

Very sorry for the delay.

When magma-nvim receives an image, it has some size (in pixels). The logic to decide which size to show the image in is as follows: if this given size fits in the current window, then it will be that size; otherwise, it will find the largest size which fits the buffer, sans its last ~2 lines.

Let's first check that that is indeed what is happening -- could you give an approximation of what your terminal's size is, in pixels? Which terminal are you using?

P.S.: if I'm not mistaken, the default size for matplotlib images (i.e., without having explicitly set figsize or dpi, which is your case) is 640x480.

FranzAtGithub commented 2 years ago

Hey,

I experience the same problem where the generated images are displayed way to big. I used a similar example code: Selection_194

Weirdly I needed to add the plt.show() command and even adding plt.ion(); plt.pause(0.001) did not help, but that maybe due to some missconfiguration on my side.

For the pyplot img I get: Selection_193

I checked and indeed the image is 640x480 in pixels. My screen resolution is 1680x1050 and my nvim is on full screen.

It is even worse with the sympy example: Selection_195

Most annoyingly the images hide the code that produced them and thus also the cursor. I also wondered were the images are placed exactly as in the first case it starts below the second line of the cell and in the second on just below the first line.

If I can provide anymore info please let me know.

Ty, for the awesome work.

dccsillag commented 2 years ago

Hey folks,

Sorry if it is a bit late, but I just had a stray thought about this -- do you use tmux? If so, does the issue still occur without it?

dccsillag commented 2 years ago

Regardless, I just did some work that should solve this. Can you confirm?

FranzAtGithub commented 2 years ago

I did not use tmux when I reported on this.

By now I switched to Fedora and Wayland for which ueberzug does not work. So I cannot use magma anymore even though I would love to.

Ty anyway for your work on this project.

Jasa-prog commented 11 months ago

Regardless, I just did some work that should solve this. Can you confirm?

I face the same issue, the matplotlib plots are displayed too big. I also noticed that the function to get_pixel_size in Outputchunk.py always returns None because the get_pty_slave() function returns None when call within nvim, but returns a number when called outside nvim. i use wezterm as terminal emulator.

benlubas commented 11 months ago

@Jasa-prog I doubt that you'll get an answer here, this plugin is pretty inactive at the moment. I'm maintaining a plugin called Molten which forked this plugin and made a bunch of improvements, including fixing this issue that you have.

Molten has a bunch of breaking changes from Magma though, so it's not a drop-in replacement