Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

title_format plot option now includes dimensions #436

Merged
merged 9 commits into from Feb 3, 2016
4 changes: 4 additions & 0 deletions holoviews/plotting/bokeh/plot.py
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
2 changes: 1 addition & 1 deletion holoviews/plotting/mpl/plot.py
Expand Up @@ -916,7 +916,7 @@ def _compute_gridspec(self, layout):

# Create title handle
if self.show_title and len(self.coords) > 1:
title = self.handles['fig'].suptitle('', **self._fontsize('title'))
title = self.handles['fig'].suptitle('', y=1.05, **self._fontsize('title'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a magic number? I assume this makes it look better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, generally avoids overlap between the plot title and the overall layout title. Not sure how best to provide control over it.

self.handles['title'] = title

return layout_subplots, layout_axes, collapsed_layout
Expand Down
55 changes: 12 additions & 43 deletions holoviews/plotting/plot.py
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.""")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely an improvement as long as the old tests pass (i.e backwards compatible).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably won't be, there may be fewer whitespace now and things may have shifted around a little bit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. That means there will be quite a lot of test data to update. We need to be careful about transient glitches and need to review the display output thoroughly.


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.rstrip(' \n')


def update_frame(self, key, ranges=None):
Expand Down Expand Up @@ -711,29 +709,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 @@ -793,15 +768,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.rstrip(' \n')


class GenericLayoutPlot(GenericCompositePlot):
Expand Down