posit-dev / positron

Positron, a next-generation data science IDE
Other
2.45k stars 73 forks source link

Plots: Add a mode that respects the intrinsic size of a plot #2052

Closed petetronic closed 6 months ago

petetronic commented 8 months ago

Positron Version:

Positron Version: 2024.01.0 (Universal) build 5

Steps to reproduce the issue:

Note: this is Feedback from Alpha Tester that was using a more complicated scenario. I created a simpler example below.

If you have a very wide or tall plot, whose intrinsic size is bigger than any realistic Plots pane size on a laptop to be readable, we need a mode to disable the scaling so the original large plot can be viewed in a windowed manner with scroll bars so the user can read the content.

This was at least observed with plots created as SVG, though there may be other scenarios in other formats that we don't provide a way to reasonably view the large content.

import graphviz
f = graphviz.Digraph()
names = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
positions = ["Manager","Team Lead B","Staff C", "Staff D", "Staff E", "Staff F", "Team Lead G", "Staff H", "Staff I", "Staff J", "Staff K", "Staff L", "Team Lead M", "Staff N", "Staff O", "Staff P", "Staff Q", "Staff R", "Team Lead S", "Staff T", "Staff U", "Staff V", "Staff W", "Team Lead X", "Staff Y", "Staff Z"]
for name, position in zip(names, positions):
    if name == "A":
        color = "lightcoral"
    elif position.startswith("Team Lead"):
        color = "lightsalmon"
    else:
        color = "lemonchiffon"
    f.node(name, position, style = "filled", color = color)

# Specify edges
f.edge("A","B"); f.edge("A","G"); f.edge("A","M"); f.edge("A","S"); f.edge("A", "X")   # Manager A to Team Leads
f.edge("B","C"); f.edge("B","D"); f.edge("B","E"); f.edge("B","F")                     # Team B relationship
f.edge("G","H"); f.edge("G","I"); f.edge("G","J"); f.edge("G","K"); f.edge("G","L")    # Team G relationship
f.edge("M","N"); f.edge("M","O"); f.edge("M","P"); f.edge("M","Q"); f.edge("M","R")    # Team M relationship
f.edge("S","T"); f.edge("S","U"); f.edge("S","V"); f.edge("S","W");                    # Team S relationship
f.edge("X","Y"); f.edge("X","Z")        

To show the image in the plots pane, you can just execute:

f

What did you expect to happen?

Either for the default, or a mode, to allow us to not resize (squish) SVG plots of very large intrinsic size. Instead, a scrollable view port of the content would allow the user to still read the information and pan around the large image.

Were there any error messages in the output or Developer Tools console?

No

petetronic commented 8 months ago

To render as a png, you should be able to add:

import IPython
IPython.display.display_png(f)
jmcphers commented 8 months ago

Zooming and panning in the Plots pane is really awkward. How would you feel about having a Zoom button instead that opens up the plot in its own window (at intrinsic size)?

petetronic commented 8 months ago

Possibly? This was requested feedback I received, and they pointed to the way it is rendered in VS Code's treatment of Jupter-like notebook cells marked under # %%, but we can review some alternate options with them?

I do see that VS Code's rendering, in addition to showing scrollable at intrinsic size inline, there is a button to launch into a custom editor preview (as well as a way to download as a file) - albeit the location of these controls could be better.

Screenshot 2024-01-11 at 2 00 23 PM
jmcphers commented 8 months ago

Oh, that's helpful. It'd be pretty easy to add a zoom level thing to the Plots pane so you could switch from Actual Size <-> Scale to Fit.

petetronic commented 6 months ago

This should be solved by #2330

jmcphers commented 6 months ago
image

We now have a 100% zoom (Excellent!), but in my testing I didn't see scrollbars and wasn't able to pan or zoom. @timtmok would you expect this to work?

timtmok commented 6 months ago

We now have a 100% zoom (Excellent!), but in my testing I didn't see scrollbars and wasn't able to pan or zoom. @timtmok would you expect this to work?

It's scroll wheel enabled and I think it's alt+scroll to scroll horizontally. There's no click+drag for panning. I do see a scrollbar for vertical but the horizontal one doesn't show up.

Also, I do have scrollbars always visible. I'll check out a release build since I'm looking at this in a dev build and I'm a behind from main.

timtmok commented 6 months ago

@jmcphers It looks good for me in build 904. Just no horizontal scrollbar, which I'm not sure why it would not be visible.

petetronic commented 6 months ago

We're going to track this work as part of #2330