Skip to content

Cannot plot PNG figures with Jupyter #810

@sarahmish

Description

@sarahmish

Environment Details

Please indicate the following details about the environment in which you found the bug:

  • SDMetrics version: 0.24.0
  • Python version: 3.10.19
  • Operating System: macos 14.6.1

Error Description

I want to make my plotly figures in PNG format, using fig.show(render='png') or

import plotly.io as pio
pio.renderers.default = 'png'

However, my plots are still using iframe renderer.

Steps to reproduce

from sdv.evaluation.single_table import get_column_plot

fig = get_column_plot(
    real_data=real_data,
    synthetic_data=synthetic_data,
    column_name='room_rate',
    metadata=metadata
)

fig.show(render='png')

produced plot is in iframe format instead of being a static png image

Image

Additional context

This issue is probably related to how sdmetrics always makes the default renderer as iframe when we are using an ipython interactive shell.

if 'ZMQInteractiveShell' in ipython_interpreter and 'iframe' in renderers:
# This means we are using jupyter notebook
pio.renderers.default = 'iframe'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnewLabel applied to new issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions