Skip to content

Commit

Permalink
Automatically apply v4 colors in template_defaults future mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed May 6, 2019
1 parent cde5358 commit 364321f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion plotly/io/_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 364321f

Please sign in to comment.