# Path: megaman/plotter/utils.py
# def _check_backend(backend):
#     def decorator(func):
#         def wrapper(*args,**kwargs):
#             import warnings
#             warnings.warn(
#                 'Be careful in using megaman.plotter modules'
#                 ' API will change in the next release.',
#                 FutureWarning
#             )
#             import pkgutil
#             package = pkgutil.find_loader(backend)
#             if package is not None:
#                 return func(*args,**kwargs)
#             else:
#                 raise ImportError('plotting backend {} not installed'.format(backend))
#         return wrapper
#     return decorator


import numpy as np
        import matplotlib.pyplot as plt
            import warnings
    import plotly.graph_objs as go
from .utils import _check_backend
    from mpl_toolkits.mplot3d import art3d, Axes3D
def scatter_plot3d_plotly(embedding, coloring=None,
                          colorscale='Rainbow', **kwargs):
    x,y,z = embedding[:,:3].T
    if isinstance(coloring, str) and coloring.lower() in 'xyz':
        color_idx = 'xyz'.find(coloring)
        coloring = embedding[:,color_idx].flatten()

    marker = kwargs.pop('marker',None)
    name = kwargs.pop('name','Embedding')
    scatter_plot = go.Scatter3d(
        x=x,
        y=y,
        z=z,
        mode='markers',
        marker=dict(
            size=2,
            opacity=0.8,
        ),
        name=name,
        **kwargs
    )
    if coloring is not None:
        scatter_plot['marker'].update(dict(
            color=coloring,
            colorscale=colorscale,
            showscale=True,
        ))
    elif marker is not None:
        scatter_plot['marker'].update(marker)


# Path: megaman/plotter/utils.py
# def _check_backend(backend):
#     def decorator(func):
#         def wrapper(*args,**kwargs):
#             import warnings
#             warnings.warn(
#                 'Be careful in using megaman.plotter modules'
#                 ' API will change in the next release.',
#                 FutureWarning
#             )
#             import pkgutil
#             package = pkgutil.find_loader(backend)
#             if package is not None:
#                 return func(*args,**kwargs)
#             else:
#                 raise ImportError('plotting backend {} not installed'.format(backend))
#         return wrapper
#     return decorator


# Path: megaman/plotter/scatter_3d.py
import numpy as np
        import matplotlib.pyplot as plt
            import warnings
    import plotly.graph_objs as go
from .utils import _check_backend
    from mpl_toolkits.mplot3d import art3d, Axes3D

def scatter_plot3d_plotly(embedding, coloring=None,
                          colorscale='Rainbow', **kwargs):
    x,y,z = embedding[:,:3].T
    if isinstance(coloring, str) and coloring.lower() in 'xyz':
        color_idx = 'xyz'.find(coloring)
        coloring = embedding[:,color_idx].flatten()

    marker = kwargs.pop('marker',None)
    name = kwargs.pop('name','Embedding')
    scatter_plot = go.Scatter3d(
        x=x,
        y=y,
        z=z,
        mode='markers',
        marker=dict(
            size=2,
            opacity=0.8,
        ),
        name=name,
        **kwargs
    )
    if coloring is not None:
        scatter_plot['marker'].update(dict(
            color=coloring,
            colorscale=colorscale,
            showscale=True,
        ))
    elif marker is not None:
        scatter_plot['marker'].update(marker)


    return [scatter_plot]