-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Changes from 4 commits
636417a
2d1597b
3ba5f74
ef40bf1
c3d4db2
5863ccb
76b935f
f67f2f8
2ee7a73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.""") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
||
|
@@ -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): | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.