2014-01-28 14:36:44 +00:00
|
|
|
# Copyright (c) 2014, GPy authors (see AUTHORS.txt).
|
|
|
|
|
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
|
|
|
|
|
2015-10-09 16:07:57 +01:00
|
|
|
current_lib = [None]
|
|
|
|
|
|
|
|
|
|
def change_plotting_library(lib):
|
|
|
|
|
try:
|
|
|
|
|
#===========================================================================
|
|
|
|
|
# Load in your plotting library here and
|
|
|
|
|
# save it under the name plotting_library!
|
|
|
|
|
# This is hooking the library in
|
|
|
|
|
# for the usage in GPy:
|
|
|
|
|
if lib == 'matplotlib':
|
|
|
|
|
import matplotlib
|
|
|
|
|
from .matplot_dep.plot_definitions import MatplotlibPlots
|
2015-10-16 14:55:04 +01:00
|
|
|
from .matplot_dep import visualize, mapping_plots, priors_plots, ssgplvm, svig_plots, variational_plots, img_plots
|
2015-10-09 16:07:57 +01:00
|
|
|
current_lib[0] = MatplotlibPlots()
|
|
|
|
|
if lib == 'plotly':
|
|
|
|
|
import plotly
|
|
|
|
|
from .plotly_dep.plot_definitions import PlotlyPlots
|
|
|
|
|
current_lib[0] = PlotlyPlots()
|
|
|
|
|
if lib == 'none':
|
|
|
|
|
current_lib[0] = None
|
|
|
|
|
#===========================================================================
|
|
|
|
|
except (ImportError, NameError):
|
2015-10-16 14:55:04 +01:00
|
|
|
raise
|
2015-10-09 16:07:57 +01:00
|
|
|
config.set('plotting', 'library', 'none')
|
2015-10-10 09:55:00 +01:00
|
|
|
import warnings
|
2015-10-10 13:32:32 +01:00
|
|
|
warnings.warn(ImportWarning("{} not available, install newest version of {} for plotting".format(lib, lib)))
|
2015-10-16 14:55:04 +01:00
|
|
|
|
2015-10-09 16:07:57 +01:00
|
|
|
from ..util.config import config
|
|
|
|
|
lib = config.get('plotting', 'library')
|
|
|
|
|
change_plotting_library(lib)
|
|
|
|
|
|
|
|
|
|
def plotting_library():
|
|
|
|
|
return current_lib[0]
|
|
|
|
|
|
|
|
|
|
def show(figure, **kwargs):
|
|
|
|
|
"""
|
|
|
|
|
Show the specific plotting library figure, returned by
|
|
|
|
|
add_to_canvas().
|
|
|
|
|
|
|
|
|
|
kwargs are the plotting library specific options
|
|
|
|
|
for showing/drawing a figure.
|
|
|
|
|
"""
|
|
|
|
|
return plotting_library().show_canvas(figure, **kwargs)
|
2015-10-02 18:26:17 +01:00
|
|
|
|
|
|
|
|
if config.get('plotting', 'library') is not 'none':
|
|
|
|
|
# Inject the plots into classes here:
|
|
|
|
|
|
|
|
|
|
# Already converted to new style:
|
|
|
|
|
from . import gpy_plot
|
2015-10-09 16:07:57 +01:00
|
|
|
|
2015-10-02 18:26:17 +01:00
|
|
|
from ..core import GP
|
|
|
|
|
GP.plot_data = gpy_plot.data_plots.plot_data
|
2015-10-10 16:39:37 +01:00
|
|
|
GP.plot_data_error = gpy_plot.data_plots.plot_data_error
|
2015-10-03 19:45:19 +01:00
|
|
|
GP.plot_errorbars_trainset = gpy_plot.data_plots.plot_errorbars_trainset
|
2015-10-03 13:59:01 +01:00
|
|
|
GP.plot_mean = gpy_plot.gp_plots.plot_mean
|
|
|
|
|
GP.plot_confidence = gpy_plot.gp_plots.plot_confidence
|
2015-10-03 19:45:19 +01:00
|
|
|
GP.plot_density = gpy_plot.gp_plots.plot_density
|
2015-10-03 21:14:32 +01:00
|
|
|
GP.plot_samples = gpy_plot.gp_plots.plot_samples
|
2015-10-04 00:05:58 +01:00
|
|
|
GP.plot = gpy_plot.gp_plots.plot
|
2015-10-04 16:10:35 +01:00
|
|
|
GP.plot_f = gpy_plot.gp_plots.plot_f
|
2015-10-05 14:10:06 +01:00
|
|
|
GP.plot_magnification = gpy_plot.latent_plots.plot_magnification
|
2015-10-09 16:07:57 +01:00
|
|
|
|
2015-10-03 19:45:19 +01:00
|
|
|
from ..core import SparseGP
|
|
|
|
|
SparseGP.plot_inducing = gpy_plot.data_plots.plot_inducing
|
2015-10-09 16:07:57 +01:00
|
|
|
|
2015-10-06 14:22:29 +01:00
|
|
|
from ..models import GPLVM, BayesianGPLVM, bayesian_gplvm_minibatch, SSGPLVM, SSMRD
|
2015-10-05 14:10:06 +01:00
|
|
|
GPLVM.plot_latent = gpy_plot.latent_plots.plot_latent
|
2015-10-07 00:52:47 +01:00
|
|
|
GPLVM.plot_scatter = gpy_plot.latent_plots.plot_latent_scatter
|
|
|
|
|
GPLVM.plot_inducing = gpy_plot.latent_plots.plot_latent_inducing
|
2015-10-05 18:47:54 +01:00
|
|
|
GPLVM.plot_steepest_gradient_map = gpy_plot.latent_plots.plot_steepest_gradient_map
|
2015-10-05 14:10:06 +01:00
|
|
|
BayesianGPLVM.plot_latent = gpy_plot.latent_plots.plot_latent
|
2015-10-07 00:52:47 +01:00
|
|
|
BayesianGPLVM.plot_scatter = gpy_plot.latent_plots.plot_latent_scatter
|
|
|
|
|
BayesianGPLVM.plot_inducing = gpy_plot.latent_plots.plot_latent_inducing
|
2015-10-05 18:47:54 +01:00
|
|
|
BayesianGPLVM.plot_steepest_gradient_map = gpy_plot.latent_plots.plot_steepest_gradient_map
|
2015-10-05 14:10:06 +01:00
|
|
|
bayesian_gplvm_minibatch.BayesianGPLVMMiniBatch.plot_latent = gpy_plot.latent_plots.plot_latent
|
2015-10-07 00:52:47 +01:00
|
|
|
bayesian_gplvm_minibatch.BayesianGPLVMMiniBatch.plot_scatter = gpy_plot.latent_plots.plot_latent_scatter
|
|
|
|
|
bayesian_gplvm_minibatch.BayesianGPLVMMiniBatch.plot_inducing = gpy_plot.latent_plots.plot_latent_inducing
|
2015-10-05 18:47:54 +01:00
|
|
|
bayesian_gplvm_minibatch.BayesianGPLVMMiniBatch.plot_steepest_gradient_map = gpy_plot.latent_plots.plot_steepest_gradient_map
|
2015-10-06 14:22:29 +01:00
|
|
|
SSGPLVM.plot_latent = gpy_plot.latent_plots.plot_latent
|
2015-10-07 00:52:47 +01:00
|
|
|
SSGPLVM.plot_scatter = gpy_plot.latent_plots.plot_latent_scatter
|
|
|
|
|
SSGPLVM.plot_inducing = gpy_plot.latent_plots.plot_latent_inducing
|
2015-10-06 14:22:29 +01:00
|
|
|
SSGPLVM.plot_steepest_gradient_map = gpy_plot.latent_plots.plot_steepest_gradient_map
|
2015-10-09 16:07:57 +01:00
|
|
|
|
2015-10-04 00:05:58 +01:00
|
|
|
from ..kern import Kern
|
2015-10-06 14:04:15 +01:00
|
|
|
Kern.plot_covariance = gpy_plot.kernel_plots.plot_covariance
|
2015-10-12 14:50:42 +01:00
|
|
|
def deprecate_plot(self, *args, **kwargs):
|
|
|
|
|
import warnings
|
|
|
|
|
warnings.warn(DeprecationWarning('Kern.plot is being deprecated and will not be available in the 1.0 release. Use Kern.plot_covariance instead'))
|
|
|
|
|
return self.plot_covariance(*args, **kwargs)
|
|
|
|
|
Kern.plot = deprecate_plot
|
2015-10-09 16:07:57 +01:00
|
|
|
Kern.plot_ARD = gpy_plot.kernel_plots.plot_ARD
|
|
|
|
|
|
2015-10-07 11:35:23 +01:00
|
|
|
from ..inference.optimization import Optimizer
|
|
|
|
|
Optimizer.plot = gpy_plot.inference_plots.plot_optimizer
|
2015-10-09 16:07:57 +01:00
|
|
|
# Variational plot!
|