-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathplotly_params.py
More file actions
220 lines (180 loc) · 5.38 KB
/
plotly_params.py
File metadata and controls
220 lines (180 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
"""Parameters for any plotting functions using plotly."""
# N.B., most of these parameters are always able to take None
# and so we set as Optional here, rather than having to repeat
# that for each function doc.
from typing import List, Literal, Mapping, Optional, Union
import plotly.graph_objects as go # type: ignore
from pydantic import Field
from typing_extensions import Annotated, TypeAlias
x_label: TypeAlias = Annotated[
Optional[str],
"X axis label.",
]
y_label: TypeAlias = Annotated[
Optional[str],
"Y axis label.",
]
fig_width: TypeAlias = Annotated[
Optional[int],
"Figure width in pixels (px).",
]
fig_height: TypeAlias = Annotated[
Optional[int],
"Figure height in pixels (px).",
]
width: TypeAlias = Annotated[
int,
"Width in pixels (px).",
]
height: TypeAlias = Annotated[
int,
"Height in pixels (px).",
]
aspect: TypeAlias = Annotated[
Optional[Literal["equal", "auto"]],
"Aspect ratio, see also https://plotly.com/python-api-reference/generated/plotly.express.imshow",
]
title: TypeAlias = Annotated[
Optional[Union[str, bool]],
"""
If True, attempt to use metadata from input dataset as a plot title.
Otherwise, use supplied value as a title.
""",
]
title_font_size = Annotated[int, "Font size for the plot title."]
text_auto: TypeAlias = Annotated[
Union[bool, str],
"""
If True or a string, single-channel img values will be displayed as text. A
string like '.2f' will be interpreted as a texttemplate numeric formatting
directive.
""",
]
color_discrete_sequence: TypeAlias = Annotated[
Optional[List], "Provide a list of colours to use."
]
color_discrete_map: TypeAlias = Annotated[
Optional[Mapping], "Provide an explicit mapping from values to colours."
]
category_order: TypeAlias = Annotated[
Optional[Union[List, Mapping]],
"Control the order in which values appear in the legend.",
]
color_continuous_scale: TypeAlias = Annotated[
Optional[Union[str, List[str]]],
"""
Colormap used to map scalar data to colors (for a 2D image). This
parameter is not used for RGB or RGBA images. If a string is provided,
it should be the name of a known color scale, and if a list is provided,
it should be a list of CSS-compatible colors.
""",
]
colorbar: TypeAlias = Annotated[
bool,
"If False, do not display a color bar.",
]
x: TypeAlias = Annotated[
str,
"Name of variable to plot on the X axis.",
]
y: TypeAlias = Annotated[
str,
"Name of variable to plot on the Y axis.",
]
z: TypeAlias = Annotated[
str,
"Name of variable to plot on the Z axis.",
]
color: TypeAlias = Annotated[
Optional[Union[str, Mapping]],
"Name of variable to use to color the markers.",
]
symbol: TypeAlias = Annotated[
Optional[Union[str, Mapping]],
"Name of the variable to use to choose marker symbols.",
]
jitter_frac: TypeAlias = Annotated[
Optional[float],
Field(ge=0, le=1),
"Randomly jitter points by this fraction of their range.",
]
marker_size: TypeAlias = Annotated[
Union[int, float],
Field(gt=0),
"Marker size.",
]
line_width: TypeAlias = Annotated[Union[int, float], "Line width."]
line_color: TypeAlias = Annotated[str, "Line color"]
template: TypeAlias = Annotated[
Optional[
Literal[
"ggplot2",
"seaborn",
"simple_white",
"plotly",
"plotly_white",
"plotly_dark",
"presentation",
"xgridoff",
"ygridoff",
"gridon",
"none",
]
],
"The figure template name (must be a key in plotly.io.templates).",
]
show: TypeAlias = Annotated[
bool,
"If true, show the plot. If False, do not show the plot, but return the figure.",
]
renderer: TypeAlias = Annotated[Optional[str], "The name of the renderer to use."]
render_mode: TypeAlias = Annotated[
Literal["auto", "svg", "webgl"],
"The type of rendering backend to use. See also https://plotly.com/python/webgl-vs-svg/",
]
render_mode_default: render_mode = "auto"
figure: TypeAlias = Annotated[
Optional[go.Figure], "A plotly figure (only returned if show=False)."
]
zmin: TypeAlias = Annotated[
Union[int, float],
"The lower end of the range of values that the colormap covers.",
]
zmax: TypeAlias = Annotated[
Union[int, float],
"The upper end of the range of values that the colormap covers.",
]
legend_sizing: TypeAlias = Annotated[
Literal["constant", "trace"],
"""
Determines if the legend items symbols scale with their corresponding
"trace" attributes or remain "constant" independent of the symbol size
on the graph.
""",
]
zoom: TypeAlias = Annotated[
Optional[Union[int, float]],
"Initial zoom level.",
]
hover_name: TypeAlias = Annotated[
Optional[Union[str, Mapping]],
"Name of variable to appear in bold in the hover tooltip.",
]
fitbounds: TypeAlias = Annotated[
Optional[Union[bool, str]],
"If False, does not auto-compute view settings to fit trace data. If 'locations', only visible locations are considered in the auto-compute. If 'geojson', the provided geojson is used.",
]
scope: TypeAlias = Annotated[
Optional[
Literal[
"africa",
"asia",
"europe",
"north america",
"south america",
"usa",
"world",
]
],
"Scope of the map.",
]