Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a35880c

Browse filesBrowse files
committed
Add mpl template function
1 parent 5830055 commit a35880c
Copy full SHA for a35880c

File tree

Expand file treeCollapse file tree

1 file changed

+91
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+91
-0
lines changed

‎packages/python/plotly/templategen/definitions.py

Copy file name to clipboardExpand all lines: packages/python/plotly/templategen/definitions.py
+91Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from templategen.utils import initialize_template
33
from .utils.colors import colors
44
import colorcet as cc
5+
import plotly.express as px
56

67
# dict of template builder functions
78
# This way we can loop over definitions in __init__.py
@@ -73,6 +74,96 @@ def ggplot2():
7374
builders["ggplot2"] = ggplot2
7475

7576

77+
def mpl():
78+
# Set colorbar_common
79+
colorbar_common = dict(
80+
outlinewidth=10,
81+
tickcolor=colors["gray14"],
82+
ticks="outside",
83+
tickwidth=2,
84+
ticklen=8,
85+
)
86+
87+
# Common axis common properties
88+
axis_common = dict(
89+
showgrid=False,
90+
gridcolor=plotly_clrs["Rhino Light 2"],
91+
linecolor=colors["gray14"],
92+
ticks="outside",
93+
showline=True,
94+
)
95+
96+
# semi-transparent black and no outline
97+
# annotation_clr = "rgb(67,103,167)"
98+
# shape_defaults = dict(fillcolor=annotation_clr, line={"width": 0}, opacity=0.5)
99+
# Near black line color, no fill
100+
annotation_clr = plotly_clrs["Rhino Core"]
101+
shape_defaults = dict(line_color=annotation_clr)
102+
103+
# Remove arrow head and make line thinner
104+
# annotation_defaults = {"arrowcolor": annotation_clr}
105+
106+
# Remove arrow head and make line thinner
107+
annotation_defaults = {
108+
"arrowcolor": annotation_clr,
109+
"arrowhead": 0,
110+
"arrowwidth": 1,
111+
}
112+
113+
template = initialize_template(
114+
paper_clr="white",
115+
font_clr=colors["gray14"],
116+
panel_background_clr="white",
117+
panel_grid_clr="white",
118+
axis_ticks_clr=colors["gray14"],
119+
zerolinecolor_clr=colors["gray14"],
120+
table_cell_clr="white",
121+
table_header_clr="white",
122+
table_line_clr="white",
123+
colorway=px.colors.qualitative.D3,
124+
colorbar_common=colorbar_common,
125+
colorscale=px.colors.sequential.Viridis,
126+
colorscale_diverging=px.colors.diverging.RdBu,
127+
axis_common=axis_common,
128+
annotation_defaults=annotation_defaults,
129+
shape_defaults=shape_defaults,
130+
)
131+
132+
# Left align title
133+
template.layout.title.x = 0.05
134+
135+
# Increase grid width for 3d plots
136+
opts = dict(gridwidth=2, gridcolor=plotly_clrs["Rhino Light 1"], zeroline=False)
137+
template.layout.scene.xaxis.update(opts)
138+
template.layout.scene.yaxis.update(opts)
139+
template.layout.scene.zaxis.update(opts)
140+
141+
# Darken ternary
142+
opts = dict(
143+
linecolor=plotly_clrs["Rhino Medium 1"], gridcolor=plotly_clrs["Rhino Light 1"]
144+
)
145+
template.layout.ternary.aaxis.update(opts)
146+
template.layout.ternary.baxis.update(opts)
147+
template.layout.ternary.caxis.update(opts)
148+
149+
# Remove lines through the origin
150+
template.layout.xaxis.update(zeroline=False)
151+
template.layout.yaxis.update(zeroline=False)
152+
153+
# Separate histogram bins wit ha white line
154+
opts = {"marker": {"line": {"width": 1, "color": "white"}}}
155+
template.data.histogram = [opts]
156+
157+
# Mapbox light style
158+
template.layout.mapbox.style = "light"
159+
160+
# Set table header font color to white
161+
return template
162+
163+
164+
builders["mpl"] = mpl
165+
166+
76167
def seaborn():
77168
# Define colors
78169
# -------------

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.