From b236896fbdfbdf494ce47035a09a11725aa08c68 Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Fri, 16 Oct 2015 14:55:04 +0100 Subject: [PATCH] [plotting] got the old way in again --- GPy/plotting/__init__.py | 4 +++- GPy/plotting/gpy_plot/plot_util.py | 7 +++++-- GPy/plotting/matplot_dep/mapping_plots.py | 2 +- GPy/plotting/matplot_dep/variational_plots.py | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/GPy/plotting/__init__.py b/GPy/plotting/__init__.py index 28c05cef..e4fe7080 100644 --- a/GPy/plotting/__init__.py +++ b/GPy/plotting/__init__.py @@ -13,6 +13,7 @@ def change_plotting_library(lib): if lib == 'matplotlib': import matplotlib from .matplot_dep.plot_definitions import MatplotlibPlots + from .matplot_dep import visualize, mapping_plots, priors_plots, ssgplvm, svig_plots, variational_plots, img_plots current_lib[0] = MatplotlibPlots() if lib == 'plotly': import plotly @@ -22,10 +23,11 @@ def change_plotting_library(lib): current_lib[0] = None #=========================================================================== except (ImportError, NameError): + raise config.set('plotting', 'library', 'none') import warnings warnings.warn(ImportWarning("{} not available, install newest version of {} for plotting".format(lib, lib))) - + from ..util.config import config lib = config.get('plotting', 'library') change_plotting_library(lib) diff --git a/GPy/plotting/gpy_plot/plot_util.py b/GPy/plotting/gpy_plot/plot_util.py index 22d6627c..e89aae0f 100644 --- a/GPy/plotting/gpy_plot/plot_util.py +++ b/GPy/plotting/gpy_plot/plot_util.py @@ -275,7 +275,7 @@ def get_x_y_var(model): and Y the outputs If (X, X_variance, Y) is given, this just returns. - + :returns: (X, X_variance, Y) """ # model given @@ -285,7 +285,10 @@ def get_x_y_var(model): else: X = model.X.values X_variance = None - Y = model.Y.values + try: + Y = model.Y.values + except AttributeError: + Y = model.Y if sparse.issparse(Y): Y = Y.todense().view(np.ndarray) return X, X_variance, Y diff --git a/GPy/plotting/matplot_dep/mapping_plots.py b/GPy/plotting/matplot_dep/mapping_plots.py index c563d392..8ec09758 100644 --- a/GPy/plotting/matplot_dep/mapping_plots.py +++ b/GPy/plotting/matplot_dep/mapping_plots.py @@ -7,7 +7,6 @@ try: from matplotlib import pyplot as pb except: pass -from .base_plots import x_frame1D, x_frame2D def plot_mapping(self, plot_limits=None, which_data='all', which_parts='all', resolution=None, levels=20, samples=0, fignum=None, ax=None, fixed_inputs=[], linecol=Tango.colorsHex['darkBlue']): @@ -52,6 +51,7 @@ def plot_mapping(self, plot_limits=None, which_data='all', which_parts='all', re ax = fig.add_subplot(111) plotdims = self.input_dim - len(fixed_inputs) + from ..gpy_plot.plot_util import x_frame1D, x_frame2D if plotdims == 1: diff --git a/GPy/plotting/matplot_dep/variational_plots.py b/GPy/plotting/matplot_dep/variational_plots.py index 24e613aa..34681552 100644 --- a/GPy/plotting/matplot_dep/variational_plots.py +++ b/GPy/plotting/matplot_dep/variational_plots.py @@ -94,7 +94,7 @@ def plot_SpikeSlab(parameterized, fignum=None, ax=None, colors=None, side_by_sid a.set_xticklabels('') # binary prob plot a = fig.add_subplot(*sub2) - a.bar(x,gamma[:,i],bottom=0.,linewidth=0,width=1.0,align='center') + a.bar(x,gamma[:,i],bottom=0.,linewidth=1.,width=1.0,align='center') a.set_xlim(x.min(), x.max()) a.set_ylim([0.,1.]) pb.draw()