Skip to content

Plotly Templates

codechembook.plotlyTemplates

chem_colorways = dict(default=['#1F77B4', '#FF7F0E', '#2CA02C', '#D62728', '#9467BD', '#8C564B', '#E377C2', '#7F7F7F', '#BCBD22', '#17BECF'], pastels=['#9dc4ff', '#dbaefe', '#ff91cd', '#ff8978', '#ffa600'], jewel=['#9966CC', '#009473', '#0F52BA', '#830E0D', '#E4D00A'], neon=['#5fe8ff', '#fc49ab', '#ff7300', '#64ff00', '#e7ff00'], reds=['#950000', '#af3d27', '#c6654c', '#db8b74', '#eeb19f', '#ffd7cb'], blues=['#004867', '#336583', '#5684a1', '#79a4bf', '#9dc5df', '#c1e7ff'], purples=['#7d2c95', '#9650a9', '#ae72bd', '#c694d2', '#ddb6e6', '#f5d9fb'], complimentary=['#0773b1', '#e79f27'], triadic=['#a23768', '#1d5700', '#e79f27'], split_complimentary=['#0773b1', '#e79f27', '#d36027'], analogous=['#a23768', '#0773b1', '#9ba0d8'], Lear=['#0773b1', '#d36027', '#A23768', '#e79f27', '#9ba0d8', '#1d5700'], greys=['#00000', '#333333', '#666666', '#999999']) module-attribute

TEMPLATE DICTIONARIES - these are each created in three parts... 1. An aux dictionary entry, which is supporting info for calculating things. This is not directly put into the final template 2. The data dictionary that will be added to the template 3. The layout dictionary that will be added to the template.

chemplate = chemplates() module-attribute


if "ChemSci" in name: # from here: https://www.rsc.org/journals-books-databases/author-and-reviewer-hub/authors-information/prepare-and-format/figures-graphics-images/#figuresgraphics dpi = 600 aratio = 210/297 # the ratio of A4 paper font_size = 7 page_width = 8.30.3937007874 # convert cm to inches font_family = "helvetica" if "2" in name: page_width = 17.10.3937007874 # this is the 2-column figure

if "Science" == name: # from https://www.science.org/content/page/instructions-preparing-initial-manuscript#preparation-of-figures dpi = 600 aratio = 8.5/11 font_size = 6 page_width = 5.70.3937007874 # convert cm to inches font_family = "helvetica" if "2" in name: page_width = 18.30.3937007874 # this is the 2-column figure

if "Nature" == name: # from https://www.nature.com/nature/for-authors/final-submission dpi = 600 aratio = 210/297 # the ratio of A4 paper font_size = 6 page_width = 8.90.3937007874 # convert cm to inches font_family = "helvetica" if "2" in name: page_width = 12.10.3937007874 # this is the 2-column figure if "3" in name: page_width = 18.4*0.3937007874 # this is the 3-column figure

if "JCP" in name: # from https://publishing.aip.org/resources/researchers/author-instructions/#graphics dpi = 600 aratio = 210/297 # the ratio of A4 paper font_size = 8 page_width = 8.50.3937007874 # convert cm to inches font_family = "helvetica" if "2" in name: page_width = 170.3937007874 # this is the 2-column figure

if "Lear" in name: dpi = 300 aratio = 1/1.61803 page_width = 2.5 font_size = 6 font_family = "helvetica" colorway = ["#0773b1", "#d36027", "#A23768", "#e79f27", "#9ba0d8", "#1d5700"] if "pres" in name: page_width = 12 page_height = 6 aratio = 0.5 font_size = 16 font_family = "avenir" if "2" in name: page_width = 6.25 aratio = 5.75/6.25

new_chemplate(name='simple_white', base_template='simple_white')

Function that generates a new template, working from a base template.

Source code in src/codechembook/plotlyTemplates.py
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
def new_chemplate(name = "simple_white", base_template = "simple_white"):
    '''
    Function that generates a new template, working from a base template. 
    '''
    new_template = copy.deepcopy(pio.templates[base_template]) # get the template for the base template


    if "data" not in new_template:
        new_template["data"] = {}
    if "layout" not in new_template:
        new_template["layout"] = {}

    if "data" not in chemplate_dicts[name]:
        chemplate_dicts[name]["data"] = {}
    if "layout" not in chemplate_dicts[name]:
        chemplate_dicts[name]["layout"] = {}

    new_template["data"].update(chemplate_dicts[name]["data"]) # update the data portion of the template with new values
    new_template["layout"].update(chemplate_dicts[name]["layout"]) # update the layout portion of the template with new values

    return go.layout.Template(new_template)