UCSD-PL / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
0 stars 7 forks source link

matplotlib output should be displayed in the Output panel when no PBs are available #44

Closed rlisahuang closed 1 year ago

rlisahuang commented 1 year ago

Example:

import matplotlib.pyplot as plt
import pandas as pd
import io

csv = '''
ID,group,time,success
P1,control,18.6,1
P2,control,15.42,1
P3,control,25.55,0
P4,control,12.56,0
P5,control,8.67,1
P6,experiment,7.31,0
P7,experiment,9.66,0
P8,experiment,13.64,1
P9,experiment,14.92,1
P10,experiment,18.47,1
'''

df = pd.read_csv(io.StringIO(csv))

fig = plt.figure()

# Create a boxplot of time for each group
## ---
ax = fig.add_subplot(1, 1, 1)
ax.boxplot([df[df['group'] == 'control']['time'],
            df[df['group'] == 'experiment']['time']],
           labels=['control', 'experiment'])

plt.show()
## ---

The plot should show up in the Output panel when Run is pressed. Right now, nothing is presented in the output panel.

KasraF commented 1 year ago

Implemented a first pass of this in 02d8bf8. We need to decide if we want to emulate the REPL or single-file run behavior before closing this issue though.

@rlisahuang @slerner Thoughts?

rlisahuang commented 1 year ago

I see that the design now is for the output to emulate the REPL.

In my opinion, I would expect a single-file run behavior when editing such code in an editor, so in other words I would like to see one final plot at the end. If I want to see intermediate plots, I probably would comment out the code afterwards.

If I put the code in a Jupyter Notebook, then I would expect REPL-like behavior based on the cells (so maybe I would put one plt.* call in each cell to see the intermediate plots.

Others might disagree. So let's keep the conversation going.

rlisahuang commented 1 year ago

Also found a bug as I was trying out this feature. See #45.

rlisahuang commented 1 year ago

Agreed upon emulating the single-file run behavior (which is what it currently is).