Exemplo n.º 1
0
    def test_plotly_main_plot(self):
        if PLOTLY_FOUND:
            # switch to plotly
            plotting.backend('plotly')

            self.assertTrue(isinstance(self.V.plot(show=False), go.Figure))

            plotting.backend('matplotlib')
Exemplo n.º 2
0
def _plot_plotly(func_args, plot_args):
    # set matplotlib backend
    backend('plotly')

    # get the variogram
    variogram = func_args['variogram']
    plot_type = func_args.get('plot_type', 'plot')

    return __plot(variogram, plot_type, **plot_args)
def test_change_plotting_backend():
    """
    Set the correct backend and check
    """
    # change to plotly
    backend('plotly')
    assert backend() == 'plotly'

    # change back
    backend('matplotlib')
    def pair_field(self, ax=None, cmap="gist_rainbow", points='all', add_points=True, alpha=0.3, **kwargs):  # pragma: no cover
        """
        Plot a pair field.

        Plot a network graph for all point pairs that fulfill the direction
        filter and lie within each others search area.

        Parameters
        ----------
        ax : matplotlib.Subplot
            A matplotlib Axes object to plot the pair field onto.
            If ``None``, a new new matplotlib figure will be created.
        cmap : string
            Any color-map name that is supported by matplotlib
        points : 'all', int, list
            If not ``'all'``, only the given coordinate (int) or 
            list of coordinates (list) will be plotted. Recommended, if
            the input data is quite large.
        add_points : bool
            If True (default) The coordinates will be added as black points.
        alpha : float
            Alpha value for the colors to make overlapping vertices
            visualize better. Defaults to ``0.3``.
            
        """
        # get the backend
        used_backend = plotting.backend()

        if used_backend == 'matplotlib':
            return plotting.matplotlib_pair_field(self, ax=ax, cmap=cmap, points=points, add_points=add_points, alpha=alpha, **kwargs)
        elif used_backend == 'plotly':
            return plotting.plotly_pair_field(self, fig=ax, points=points, add_points=add_points, alpha=alpha, **kwargs)       
def test_backend_no_args():
    """
    The default backend should be 'matplotlib'
    """
    assert backend() == 'matplotlib'
def test_raise_value_error():
    """
    Raise a value error by setting the wrong backend
    """
    with pytest.raises(ValueError):
        backend('not-a-backend')
# -------------
#
# 4.3.1 :func:`Variogram.plot <skgstat.Variogram.plot>`
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# The :func:`Variogram.plot <skgstat.Variogram.plot>` is the main plotting
# function in SciKit-GStat.
# Before you use the variogram for further geostatistical methods, like kriging,
# or further analysis, make sure, that a suitable model was found and fitted
# to the experimental data. Further, you have to make sure that the statistical
# foundation of this estimation is sound, the lag classes are well designed and
# backed by a suiatable amount of data.
# Otherwise, any other geostatistical analysis or method will have to fail,
# no matter how nice the results might look like.

# from skgstat.plotting import backend
backend('plotly')

# %%
# Plotly
# """"""
fig = V.plot(show=False)
fig

# %%
# A useful argument for ``plot`` is the ``ax``, this takes a
# ``matplotlib.AxesSubplot`` for the ``'matplotlib'`` backend and a
# ``plotly.Figure`` for the  ``'plotly'`` backend.
# You need to supply the correct amount of subplots (two). For convenience,
# the histogram in the upper subplot can be disabled.
fig = make_subplots(rows=1, cols=1)
fig.update_layout(width=800,