joouha / euporie

Jupyter notebooks in the terminal
https://euporie.readthedocs.io
MIT License
1.54k stars 36 forks source link

Plots are truncated #67

Closed twrightsman closed 1 year ago

twrightsman commented 1 year ago

Plots seem to be truncated; is there any way to fix this? See the image below:

truncated

joouha commented 1 year ago

Hi - what terminal are you using?

twrightsman commented 1 year ago

Hello! This screenshot is using the Foot terminal inside a tmux session.

twrightsman commented 1 year ago

I realized that I forgot to mention I'm using mosh. After testing with vanilla ssh the plots look fine and not truncated! I'll modify the title accordingly, since it would be nice to work also with mosh.

twrightsman commented 1 year ago

Well, I guess I spoke too soon... The following is over SSH, in a remote tmux session, using the Foot terminal on the client. tmux_graphics are enabled.

truncated

twrightsman commented 1 year ago

I did some further investigation using the latest dev commit (https://github.com/joouha/euporie/commit/f1cdd080e442827c69fca2bfd19f71a42642cdc1) and this seems to be a Foot terminal-specific issue...

I ran euporie-notebook inside of tmux and then joined that session from both Foot and GNOME Terminal. When I plot something through Foot, the plot is truncated. However, if I move to another cell and back to the plotted cell in GNOME Terminal, the plot resizes to the correct shape, including in the tmux session connected through Foot. Then when I move to another cell and back in Foot, the plot becomes truncated again in both terminals.

joouha commented 1 year ago

I believe this is because the default ANSI image renderer, timg, assumes a 2x1 terminal character aspect ratio.

Foot appears to favour slightly taller character aspect ratios, hence the truncated graphics.

I suggest you install chafa.py in the same environment as euporie - it's a far superior ANSI image renderer, and supports custom character aspect ratios to boot, so this should solve your issue.

I'm contemplating making chafa.py the default image renderer in euporie (so it gets installed as a required dependency by default).

joouha commented 1 year ago

Actually I think I might have now fixed the issue with timg in dev with aec3a1d1be008d66c83c049d74da34d195b295b5 and 46cb73beffdc2610c3e2129b32cea7e88448248b, by resizing images before rendering to work around the 2x1 aspect ratio assumption.

twrightsman commented 1 year ago

Thanks for taking another look at this; things look a lot better!

screenshot

Will euporie auto-detect the presence of chafa.py if I install it and use it over timg?

twrightsman commented 1 year ago

I'm happy to open a separate issue for this, but after installing chafa.py I get (Format Conversion Error) after plotting.

format-conversion-error

twrightsman commented 1 year ago

I think we can consider this fixed, thank you! I migrated the chafa.py bug to it's own issue.