Skip to content

Commit fdd86f5

Browse files
committed
Don't quote strings in FacetGrid titles
`model = foo` looks better than `model = 'foo'` or `model = u'foo'`. This is also consistent with what Seaborn does.
1 parent 3d11031 commit fdd86f5

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

xray/core/formatting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ def format_timedelta(t, timedelta_format=None):
8989
return timedelta_str
9090

9191

92-
def format_item(x, timedelta_format=None):
92+
def format_item(x, timedelta_format=None, quote_strings=True):
9393
"""Returns a succinct summary of an object as a string"""
9494
if isinstance(x, (np.datetime64, datetime)):
9595
return format_timestamp(x)
9696
if isinstance(x, (np.timedelta64, timedelta)):
9797
return format_timedelta(x, timedelta_format=timedelta_format)
9898
elif isinstance(x, (unicode_type, bytes_type)):
99-
return repr(x)
99+
return repr(x) if quote_strings else x
100100
elif isinstance(x, (float, np.float)):
101101
return '{0:.4}'.format(x)
102102
else:

xray/plot/facetgrid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _nicetitle(coord, value, maxchar, template):
2121
"""
2222
Put coord, value in template and truncate at maxchar
2323
"""
24-
prettyvalue = format_item(value)
24+
prettyvalue = format_item(value, quote_strings=False)
2525
title = template.format(coord=coord, value=prettyvalue)
2626

2727
if len(title) > maxchar:

xray/test/test_plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,10 @@ def test_bad_x_string_exception(self):
456456

457457
def test_default_title(self):
458458
a = DataArray(easy_array((4, 3, 2)), dims=['a', 'b', 'c'])
459-
a.coords['d'] = 10
459+
a.coords['d'] = u'foo'
460460
self.plotfunc(a.isel(c=1))
461461
title = plt.gca().get_title()
462-
self.assertEqual('c = 1, d = 10', title)
462+
self.assertEqual('c = 1, d = foo', title)
463463

464464
def test_colorbar_label(self):
465465
self.darray.name = 'testvar'

0 commit comments

Comments
 (0)