Skip to content

Commit

Permalink
Merge pull request #436 from ioam/dim_title
Browse files Browse the repository at this point in the history
The title_format plot option now includes dimensions
  • Loading branch information
jlstevens committed Feb 3, 2016
2 parents cc2cf63 + 2ee7a73 commit 4e3e0bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 43 deletions.
4 changes: 4 additions & 0 deletions holoviews/plotting/bokeh/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class BokehPlot(DimensionedPlot):
share their Bokeh data source allowing for linked brushing
and other linked behaviors.""")

title_format = param.String(default="{label} {group} - {dimensions}", doc="""
The formatting string for the title of this plot, allows defining
a label group separator and dimension labels.""")

renderer = BokehRenderer

def __init__(self, *args, **params):
Expand Down
55 changes: 12 additions & 43 deletions holoviews/plotting/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ class DimensionedPlot(Plot):
show_title = param.Boolean(default=True, doc="""
Whether to display the plot title.""")

title_format = param.String(default="{label} {group}", doc="""
The formatting string for the title of this plot.""")
title_format = param.String(default="{label} {group}\n{dimensions}", doc="""
The formatting string for the title of this plot, allows defining
a label group separator and dimension labels.""")

normalize = param.Boolean(default=True, doc="""
Whether to compute ranges across all Elements at this level
Expand Down Expand Up @@ -558,20 +559,17 @@ def _format_title(self, key, separator='\n'):
type_name = type(frame).__name__
group = frame.group if frame.group != type_name else ''
label = frame.label

dim_title = self._frame_title(key, separator=separator)
if self.layout_dimensions:
title = ''
title = dim_title
else:
title_format = util.safe_unicode(self.title_format)
title = title_format.format(label=util.safe_unicode(label),
group=util.safe_unicode(group),
type=type_name)
dim_title = self._frame_title(key, separator=separator)
if not title or title.isspace():
return dim_title
elif not dim_title or dim_title.isspace():
return title
else:
return separator.join([title, dim_title])
type=type_name,
dimensions=dim_title)
return title.strip(' \n')


def update_frame(self, key, ranges=None):
Expand Down Expand Up @@ -713,29 +711,6 @@ def get_extents(self, overlay, ranges):
return util.max_extents(extents, self.projection == '3d')


def _format_title(self, key, separator='\n'):
frame = self._get_frame(key)
if frame is None: return None

type_name = type(frame).__name__
group = frame.group if frame.group != type_name else ''
label = frame.label
if self.layout_dimensions:
title = ''
else:
title_format = util.safe_unicode(self.title_format)
title = title_format.format(label=util.safe_unicode(label),
group=util.safe_unicode(group),
type=type_name)
dim_title = self._frame_title(key, 2)
if not title or title.isspace():
return dim_title
elif not dim_title or dim_title.isspace():
return title
else:
return separator.join([title, dim_title])



class GenericCompositePlot(DimensionedPlot):

Expand Down Expand Up @@ -795,15 +770,9 @@ def _format_title(self, key, separator='\n'):
label = util.safe_unicode(layout.label)
title = util.safe_unicode(self.title_format).format(label=label,
group=group,
type=type_name)
title = '' if title.isspace() else title
if not title:
return dim_title
elif not dim_title:
return title
else:
return separator.join([title, dim_title])

type=type_name,
dimensions=dim_title)
return title.strip(' \n')


class GenericLayoutPlot(GenericCompositePlot):
Expand Down

0 comments on commit 4e3e0bf

Please sign in to comment.