88import json
99from functools import reduce
1010
11+ from six import string_types
12+
13+ from _plotly_future_ import _future_flags
14+
1115try :
1216 from math import gcd
1317except ImportError :
@@ -33,7 +37,8 @@ def __init__(self):
3337 # Initialize built-in templates
3438 default_templates = ['ggplot2' , 'seaborn' ,
3539 'plotly' , 'plotly_white' ,
36- 'plotly_dark' , 'presentation' , 'xgridoff' ]
40+ 'plotly_dark' , 'presentation' , 'xgridoff' ,
41+ 'plotly_v4_colors' ]
3742
3843 for template_name in default_templates :
3944 self ._templates [template_name ] = Lazy
@@ -62,6 +67,14 @@ def __getitem__(self, item):
6267 template_str = pkgutil .get_data ('plotly' , path ).decode ('utf-8' )
6368 template_dict = json .loads (template_str )
6469 template = Template (template_dict )
70+
71+ if ('template_defaults' in _future_flags
72+ and isinstance (item , string_types )
73+ and item in ('plotly' , 'plotly_white' , 'plotly_dark' )
74+ ):
75+ template = self .merge_templates (
76+ template , self ['plotly_v4_colors' ])
77+
6578 self ._templates [item ] = template
6679
6780 return template
0 commit comments