Skip to content

Commit

Permalink
Defaulting to matplotlib ticking behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jun 18, 2015
1 parent 7395d9a commit 62e1e58
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion holoviews/plotting/mpl/chart.py
Expand Up @@ -291,11 +291,13 @@ def _compute_ticks(self, view, edges, widths, lims):
Compute the ticks either as cyclic values in degrees or as roughly
evenly spaced bin centers.
"""
if self.xticks is None:
return None
if self.cyclic:
x0, x1, _, _ = lims
xvals = np.linspace(x0, x1, self.xticks)
labels = ["%.0f" % np.rad2deg(x) + '\N{DEGREE SIGN}' for x in xvals]
else:
elif self.xticks:
dim = view.get_dimension(0)
inds = np.linspace(0, len(edges)-1, self.xticks, dtype=np.int)
xvals = [edges[i] for i in inds]
Expand Down
12 changes: 6 additions & 6 deletions holoviews/plotting/mpl/element.py
Expand Up @@ -75,7 +75,7 @@ class ElementPlot(GenericElementPlot, MPLPlot):
zaxis = param.Boolean(default=True, doc="""
Whether to display the z-axis.""")

xticks = param.Integer(default=5, doc="""
xticks = param.Parameter(default=None, doc="""
Number of ticks along the x-axis.""")

xticker = param.ClassSelector(default=None, class_=ticker.Locator, doc="""
Expand All @@ -84,7 +84,7 @@ class ElementPlot(GenericElementPlot, MPLPlot):
xrotation = param.Integer(default=0, bounds=(0, 360), doc="""
Rotation angle of the xticks.""")

yticks = param.Integer(default=5, doc="""
yticks = param.Parameter(default=None, doc="""
Number of ticks along the y-axis.""")

yticker = param.ClassSelector(default=None, class_=ticker.Locator, doc="""
Expand All @@ -96,7 +96,7 @@ class ElementPlot(GenericElementPlot, MPLPlot):
zrotation = param.Integer(default=0, bounds=(0, 360), doc="""
Rotation angle of the xticks.""")

zticks = param.Integer(default=5, doc="""
zticks = param.Parameter(default=None, doc="""
Number of ticks along the z-axis.""")

zticker = param.ClassSelector(default=None, class_=ticker.Locator, doc="""
Expand Down Expand Up @@ -281,7 +281,7 @@ def _finalize_ticks(self, axis, xticks, yticks, zticks):
log_locator = ticker.LogLocator(numticks=self.xticks,
subs=range(1,10))
axis.xaxis.set_major_locator(log_locator)
elif self.xticks:
elif self.xticks is not None:
axis.xaxis.set_major_locator(ticker.MaxNLocator(self.xticks))

for tick in axis.get_xticklabels():
Expand All @@ -296,7 +296,7 @@ def _finalize_ticks(self, axis, xticks, yticks, zticks):
log_locator = ticker.LogLocator(numticks=self.yticks,
subs=range(1,10))
axis.yaxis.set_major_locator(log_locator)
elif self.yticks:
elif self.yticks is not None:
axis.yaxis.set_major_locator(ticker.MaxNLocator(self.yticks))

if not self.projection == '3d':
Expand All @@ -310,7 +310,7 @@ def _finalize_ticks(self, axis, xticks, yticks, zticks):
log_locator = ticker.LogLocator(numticks=self.zticks,
subs=range(1,10))
axis.zaxis.set_major_locator(log_locator)
else:
elif self.zticks is not None:
axis.zaxis.set_major_locator(ticker.MaxNLocator(self.zticks))

if self.projection == '3d':
Expand Down
4 changes: 2 additions & 2 deletions holoviews/plotting/mpl/pandas.py
Expand Up @@ -51,10 +51,10 @@ class DFrameViewPlot(ElementPlot):
'hist_kwds', 'density_kwds'],
'autocorrelation': ['kwds']}

xticks = param.Number(default=0, doc="""
xticks = param.Number(default=None, doc="""
By default we don't mess with Pandas based tickmarks""")

yticks = param.Number(default=0, doc="""
yticks = param.Number(default=None, doc="""
By default we don't mess with Pandas based tickmarks""")

style_opts = list({opt for opts in dframe_options.values() for opt in opts})
Expand Down

0 comments on commit 62e1e58

Please sign in to comment.