diff --git a/GPy/installation.cfg b/GPy/installation.cfg index 28fd45b5..2056c0b9 100644 --- a/GPy/installation.cfg +++ b/GPy/installation.cfg @@ -1,5 +1,5 @@ # This is the local installation configuration file for GPy [plotting] -library = plotly -#library = matplotlib \ No newline at end of file +#library = plotly +library = matplotlib \ No newline at end of file diff --git a/GPy/plotting/gpy_plot/plot_util.py b/GPy/plotting/gpy_plot/plot_util.py index 21208d3d..59845bc3 100644 --- a/GPy/plotting/gpy_plot/plot_util.py +++ b/GPy/plotting/gpy_plot/plot_util.py @@ -341,7 +341,7 @@ def x_frame1D(X,plot_limits=None,resolution=None): xmin,xmax = X.mean.min(0),X.mean.max(0) else: xmin,xmax = X.min(0),X.max(0) - xmin, xmax = xmin-0.2*(xmax-xmin), xmax+0.2*(xmax-xmin) + xmin, xmax = xmin-0.25*(xmax-xmin), xmax+0.25*(xmax-xmin) elif len(plot_limits)==2: xmin, xmax = plot_limits else: @@ -357,7 +357,7 @@ def x_frame2D(X,plot_limits=None,resolution=None): assert X.shape[1]==2, "x_frame2D is defined for two-dimensional inputs" if plot_limits is None: xmin, xmax = X.min(0),X.max(0) - xmin, xmax = xmin-0.2*(xmax-xmin), xmax+0.2*(xmax-xmin) + xmin, xmax = xmin-0.075*(xmax-xmin), xmax+0.075*(xmax-xmin) elif len(plot_limits)==2: xmin, xmax = plot_limits elif len(plot_limits)==4: diff --git a/GPy/plotting/plotly_dep/defaults.py b/GPy/plotting/plotly_dep/defaults.py index 6b82fc3a..7785602d 100644 --- a/GPy/plotting/plotly_dep/defaults.py +++ b/GPy/plotting/plotly_dep/defaults.py @@ -48,7 +48,7 @@ data_2d = dict(marker='o', cmap='Hot', marker_kwargs=dict(opacity=1., size='10', inducing_1d = dict(color=Tango.colorsHex['darkRed']) inducing_2d = dict(marker_kwargs=dict(size='8', opacity=.7, line=Line(width=.5, color='black')), opacity=.7, color='white', marker='star-triangle-up') inducing_3d = dict(marker_kwargs=dict(size='8', opacity=.7, line=Line(width=.5, color='black')), opacity=.7, color='white', marker='star-triangle-up') -# xerrorbar = dict(color='k', fmt='none', elinewidth=.5, alpha=.5) +xerrorbar = dict(color='black', error_kwargs=dict(thickness=.5), opacity=.5) yerrorbar = dict(color=Tango.colorsHex['darkRed'], error_kwargs=dict(thickness=.5), opacity=.5) # # # GP plots: @@ -69,8 +69,8 @@ confidence_interval = dict(mode='lines', line_kwargs=dict(color=Tango.colorsHex[ # ard = dict(edgecolor='k', linewidth=1.2) # # # Input plots: -latent = dict(colorscale='Greys', reversescale=True) +latent = dict(colorscale='Greys', reversescale=True, zsmooth='best') gradient = dict(colorscale='RdBu', opacity=.7) -magnification = dict(colorscale='Greys') +magnification = dict(colorscale='Greys', zsmooth='best', reversescale=True) latent_scatter = dict(marker_kwargs=dict(size='15', opacity=.7)) # annotation = dict(fontdict=dict(family='sans-serif', weight='light', fontsize=9), zorder=.3, alpha=.7) \ No newline at end of file diff --git a/GPy/plotting/plotly_dep/plot_definitions.py b/GPy/plotting/plotly_dep/plot_definitions.py index 8119cc4e..4b06658c 100644 --- a/GPy/plotting/plotly_dep/plot_definitions.py +++ b/GPy/plotting/plotly_dep/plot_definitions.py @@ -171,9 +171,16 @@ class PlotlyPlots(AbstractPlottingLibrary): else: error_kwargs.update(dict(array=error, symmetric=True)) if Z is not None: - return Scatter3d(x=X, y=Y, z=Z, mode='markers', error_x=ErrorX(color=color, **error_kwargs or {}), showlegend=label is not None, marker=Marker(size='0'), name=label, **kwargs) - return Scatter(x=X, y=Y, mode='markers', error_x=ErrorX(color=color, **error_kwargs or {}), showlegend=label is not None, marker=Marker(size='0'), name=label, **kwargs) - + return Scatter3d(x=X, y=Y, z=Z, mode='markers', + error_x=ErrorX(color=color, **error_kwargs or {}), + marker=Marker(size='0'), name=label, + showlegend=label is not None, **kwargs) + return Scatter(x=X, y=Y, mode='markers', + error_x=ErrorX(color=color, **error_kwargs or {}), + marker=Marker(size='0'), name=label, + showlegend=label is not None, + **kwargs) + def yerrorbar(self, ax, X, Y, error, Z=None, color=Tango.colorsHex['mediumBlue'], label=None, error_kwargs=None, **kwargs): error_kwargs = error_kwargs or {} if (error.shape[0] == 2) and (error.ndim == 2): @@ -195,8 +202,8 @@ class PlotlyPlots(AbstractPlottingLibrary): if not 'showscale' in imshow_kwargs: imshow_kwargs['showscale'] = False return Heatmap(z=X, name=label, - x0=extent[0], dx=float(extent[1]-extent[0])/X.shape[0], - y0=extent[2], dy=float(extent[3]-extent[2])/X.shape[1], + x0=extent[0], dx=float(extent[1]-extent[0])/(X.shape[0]-1), + y0=extent[2], dy=float(extent[3]-extent[2])/(X.shape[1]-1), zmin=vmin, zmax=vmax, showlegend=label is not None, hoverinfo='z', @@ -206,20 +213,26 @@ class PlotlyPlots(AbstractPlottingLibrary): # TODO stream interaction? super(PlotlyPlots, self).imshow_interact(ax, plot_function) - def annotation_heatmap(self, ax, X, annotation, extent=None, label=None, imshow_kwargs=None, **annotation_kwargs): - imshow = self.imshow(ax, X, extent, label, **imshow_kwargs) + def annotation_heatmap(self, ax, X, annotation, extent=None, label='Gradient', imshow_kwargs=None, **annotation_kwargs): + imshow_kwargs.setdefault('label', label) + imshow_kwargs.setdefault('showscale', True) + imshow = self.imshow(ax, X, extent, **imshow_kwargs) + X = X-X.min() + X /= X.max()/2. + X -= 1 x = np.linspace(extent[0], extent[1], X.shape[0]) - y = np.linspace(extent[0], extent[1], X.shape[0]) + y = np.linspace(extent[2], extent[3], X.shape[1]) annotations = Annotations() for n, row in enumerate(annotation): for m, val in enumerate(row): - #var = z[n][m] + var = X[n][m] annotations.append( Annotation( text=str(val), x=x[m], y=y[n], xref='x1', yref='y1', - font=dict(color='white' if val > 0.5 else 'black'), + font=dict(color='white' if np.abs(var) > 0.8 else 'black', size=10), + opacity=.5, showarrow=False)) return imshow, annotations @@ -228,7 +241,7 @@ class PlotlyPlots(AbstractPlottingLibrary): def contour(self, ax, X, Y, C, levels=20, label=None, **kwargs): return Contour(x=X, y=Y, z=C, - ncontours=levels, contours=Contours(start=C.min(), end=C.max(), size=(C.max()-C.min())/levels), + #ncontours=levels, contours=Contours(start=C.min(), end=C.max(), size=(C.max()-C.min())/levels), name=label, **kwargs) def surface(self, ax, X, Y, Z, color=None, label=None, **kwargs):