Skip to content

Commit

Permalink
Add a function to set the plotly default render depending on the envi…
Browse files Browse the repository at this point in the history
…ronment.
  • Loading branch information
pvk-developer committed Nov 6, 2023
1 parent d7a8888 commit 4ea6eb1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sdmetrics/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,30 @@
import pandas as pd
import plotly.express as px
import plotly.figure_factory as ff
import plotly.io as pio
from pandas.api.types import is_datetime64_dtype

from sdmetrics.reports.utils import PlotConfig
from sdmetrics.utils import get_missing_percentage, is_datetime


def _set_plotly_config():
"""Set the ``plotly`` config according to the environment."""
renderers = list(pio.renderers)
if getattr('get_ipython', __builtin__):
ipython_interpreter = get_ipython()
if 'colab' in ipython_interpreter and 'colab' in renderers:
pio.renderers.default = 'colab'
elif 'ZMQInteractiveShell' in ipython_interpreter and 'notebook' in renderers:
pio.renderers.default = 'notebook'

elif 'iframe' in renderers:
pio.renderers.default = 'iframe'


_set_plotly_config()


def _generate_column_bar_plot(real_data, synthetic_data, plot_kwargs={}):
"""Generate a bar plot of the real and synthetic data.
Expand Down

0 comments on commit 4ea6eb1

Please sign in to comment.