Skip to content

Commit

Permalink
Added plot option to control which axis labels to display
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 11, 2016
1 parent 504f2dc commit 37f2066
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions holoviews/plotting/mpl/chart3d.py
Expand Up @@ -33,6 +33,9 @@ class Plot3D(ColorbarPlot):
bgcolor = param.String(default='white', doc="""
Background color of the axis.""")

labelled = param.List(default=['x', 'y', 'z'], doc="""
Specifies the list of axes to display the labels on.""")

projection = param.ObjectSelector(default='3d', objects=['3d'], doc="""
The projection of the matplotlib axis.""")

Expand Down
12 changes: 9 additions & 3 deletions holoviews/plotting/mpl/element.py
Expand Up @@ -45,6 +45,9 @@ class ElementPlot(GenericElementPlot, MPLPlot):
invert_zaxis = param.Boolean(default=False, doc="""
Whether to invert the plot z-axis.""")

labelled = param.List(default=['x', 'y'], doc="""
Whether to plot the 'x' and 'y' labels""")

logx = param.Boolean(default=False, doc="""
Whether to apply log scaling to the x-axis of the Chart.""")

Expand Down Expand Up @@ -254,9 +257,12 @@ def _set_labels(self, axes, dimensions, xlabel=None, ylabel=None, zlabel=None):
xlabel, ylabel, zlabel = self._get_axis_labels(dimensions, xlabel, ylabel, zlabel)
if self.invert_axes:
xlabel, ylabel = ylabel, xlabel
if xlabel and self.xaxis: axes.set_xlabel(xlabel, **self._fontsize('xlabel'))
if ylabel and self.yaxis: axes.set_ylabel(ylabel, **self._fontsize('ylabel'))
if zlabel and self.zaxis: axes.set_zlabel(zlabel, **self._fontsize('zlabel'))
if xlabel and self.xaxis and 'x' in self.labelled:
axes.set_xlabel(xlabel, **self._fontsize('xlabel'))
if ylabel and self.yaxis and 'y' in self.labelled:
axes.set_ylabel(ylabel, **self._fontsize('ylabel'))
if zlabel and self.zaxis and 'z' in self.labelled:
axes.set_zlabel(zlabel, **self._fontsize('zlabel'))


def _set_axis_formatter(self, axis, dim):
Expand Down
6 changes: 5 additions & 1 deletion holoviews/plotting/mpl/plot.py
Expand Up @@ -8,7 +8,7 @@
import param
from ...core import (OrderedDict, HoloMap, AdjointLayout, NdLayout,
GridSpace, Element, CompositeOverlay, Empty,
Collator)
Collator, GridMatrix)
from ...core.options import Store, Compositor
from ...core.util import int_to_roman, int_to_alpha, basestring
from ...core import traversal
Expand Down Expand Up @@ -393,6 +393,10 @@ def _create_subplots(self, layout, axis, ranges, create_axes):
r == self.rows//2):
kwargs['show_legend'] = self.show_legend
kwargs['legend_position'] = 'right'
if (not isinstance(self.layout, GridMatrix) and not
((c == self.cols//2 and r == 0) or
(c == 0 and r == self.rows//2))):
kwargs['labelled'] = []

# Create subplot
if view is not None:
Expand Down
1 change: 1 addition & 0 deletions holoviews/plotting/mpl/raster.py
Expand Up @@ -244,6 +244,7 @@ class RasterGridPlot(GridPlot, OverlayPlot):
invert_xaxis = param.Parameter(precedence=-1)
invert_yaxis = param.Parameter(precedence=-1)
invert_zaxis = param.Parameter(precedence=-1)
labelled = param.Parameter(precedence=-1)
legend_cols = param.Parameter(precedence=-1)
legend_position = param.Parameter(precedence=-1)
logx = param.Parameter(precedence=-1)
Expand Down

0 comments on commit 37f2066

Please sign in to comment.