mckinsey / vizro

Vizro is a toolkit for creating modular data visualization applications.
https://vizro.readthedocs.io/en/stable/
Apache License 2.0
2.63k stars 117 forks source link

[Bug] Fix duplicate figure display in jupyter notebook #527

Closed nadijagraca closed 2 months ago

nadijagraca commented 3 months ago

Description

Issue:

Possible combinations and outcomes (with merging this PR) Configuration explain return_elements Outcome
fig = vizro_ai.plot(...) Fig not displayed, fig.show() needed
fig = vizro_ai.plot(...) Fig not displayed, fig.show() needed, MD displayed
output_dataclass = vizro_ai.plot(...) Fig not displayed, output_dataclass.figure.show() needed
output_dataclass = vizro_ai.plot(...) Fig not displayed, output_dataclass.figure.show() needed, MD displayed
vizro_ai.plot(...) Fig displayed
vizro_ai.plot(...) Fig and MD displayed
vizro_ai.plot(...) Fig not displayed, PlotOutputs printed
vizro_ai.plot(...) Fig not displayed, MD and PlotOutputs displayed

Changes:

Screenshot

Notice

maxschulz-COL commented 3 months ago

Configuration explain return_elements Outcome fig = vizro_ai.plot(...) ❌ ❌ Fig not displayed, fig.show() needed fig = vizro_ai.plot(...) ✅ ❌ Fig not displayed, fig.show() needed, MD displayed fig = vizro_ai.plot(...) ❌ ✅ Fig not displayed, fig.show() needed --> Incorrect? This would beed fig.figure.show()? fig = vizro_ai.plot(...) ✅ ✅ Fig not displayed, fig.show() needed, MD displayed --> Incorrect? This would beed fig.figure.show()? vizro_ai.plot(...) ❌ ❌ Fig displayed, MD and PlotOutputs printed --> Incorrect? Why would anything be printed? vizro_ai.plot(...) ✅ ❌ Fig and MD displayed vizro_ai.plot(...) ❌ ✅ Fig not displayed, PlotOutputs printed vizro_ai.plot(...) ✅ ✅ Fig not displayed, MD and PlotOutputs displayed --> MD displayed and PlotOutputs printed?

After our PS last week, this is what I expected? Do you agree @Anna-Xiong @nadijagraca ?

maxschulz-COL commented 3 months ago

Configuration explain return_elements Outcome fig = vizro_ai.plot(...) ❌ ❌ Fig not displayed, fig.show() needed fig = vizro_ai.plot(...) ✅ ❌ Fig not displayed, fig.show() needed, MD displayed fig = vizro_ai.plot(...) ❌ ✅ Fig not displayed, fig.show() needed --> Incorrect? This would beed fig.figure.show()? fig = vizro_ai.plot(...) ✅ ✅ Fig not displayed, fig.show() needed, MD displayed --> Incorrect? This would beed fig.figure.show()? vizro_ai.plot(...) ❌ ❌ Fig displayed, MD and PlotOutputs printed --> Incorrect? Why would anything be printed? vizro_ai.plot(...) ✅ ❌ Fig and MD displayed vizro_ai.plot(...) ❌ ✅ Fig not displayed, PlotOutputs printed vizro_ai.plot(...) ✅ ✅ Fig not displayed, MD and PlotOutputs displayed --> MD displayed and PlotOutputs printed?

After our PS last week, this is what I expected? Do you agree @Anna-Xiong @nadijagraca ?

@Anna-Xiong What I meant is that there are 4 cases in Nadjas description that are either wrong, or the actual behaviour is wrong. I was just thinking that you could clarify whether its just the description that is wrong, or the actual behaviour (look for the --> above)

Anna-Xiong commented 2 months ago

Hi @maxschulz-COL i think overall it aligns with what we discussed a week ago. Only minor difference is this one

Configuration explain return_elements Outcome
vizro_ai.plot(...) Fig displayed, MD and PlotOutputs printed

MD and PlotOutputs printed is not true here, but fig is displayed. Is there any particular case you observed to be different from what we discussed?