From 364321f827e8d6745eea1cad35920b16a2487e4c Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Sun, 5 May 2019 07:40:23 -0400 Subject: [PATCH] Automatically apply v4 colors in template_defaults future mode --- plotly/io/_templates.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plotly/io/_templates.py b/plotly/io/_templates.py index fd185e78f2..71fe33333d 100644 --- a/plotly/io/_templates.py +++ b/plotly/io/_templates.py @@ -8,6 +8,10 @@ import json from functools import reduce +from six import string_types + +from _plotly_future_ import _future_flags + try: from math import gcd except ImportError: @@ -33,7 +37,8 @@ def __init__(self): # Initialize built-in templates default_templates = ['ggplot2', 'seaborn', 'plotly', 'plotly_white', - 'plotly_dark', 'presentation', 'xgridoff'] + 'plotly_dark', 'presentation', 'xgridoff', + 'plotly_v4_colors'] for template_name in default_templates: self._templates[template_name] = Lazy @@ -62,6 +67,14 @@ def __getitem__(self, item): template_str = pkgutil.get_data('plotly', path).decode('utf-8') template_dict = json.loads(template_str) template = Template(template_dict) + + if ('template_defaults' in _future_flags + and isinstance(item, string_types) + and item in ('plotly', 'plotly_white', 'plotly_dark') + ): + template = self.merge_templates( + template, self['plotly_v4_colors']) + self._templates[item] = template return template