Plotting utils
plotting_utils
¶
Attributes¶
COLORS
module-attribute
¶
COLORS = (
"blue",
"red",
"green",
"black",
"orange",
"purple",
"brown",
"cyan",
)
The colours used when a trace does not prescribe one.
DASHES
module-attribute
¶
DASHES = ('solid', 'dash', 'dot', 'dashdot')
The dash patterns used to distinguish the traces of superposed sources.
DASH_ALIASES
module-attribute
¶
DASH_ALIASES = {
"-": "solid",
"--": "dash",
"-.": "dashdot",
":": "dot",
"..": "dot",
}
The Matplotlib dash patterns mapped to their Plotly counterparts.
MARKER_ALIASES
module-attribute
¶
MARKER_ALIASES = {
".": "circle",
"o": "circle",
"x": "x",
"+": "cross",
"s": "square",
"^": "triangle-up",
"v": "triangle-down",
"*": "star",
"d": "diamond",
}
The Matplotlib marker symbols mapped to their Plotly counterparts.
Classes¶
Functions:¶
get_formatted_value
¶
get_formatted_value(
value, precision: int = FLOAT_PRECISION
)
Rounds either a float or a NumPy array.
Parameters:
-
value–The data to round.
-
precision(int, default:FLOAT_PRECISION) –The rounding precision.
Returns: The rounded data.
Source code in src\vimseo\utilities\plotting_utils.py
320 321 322 323 324 325 326 327 328 329 330 331 332 | |
superpose_curves
¶
superpose_curves(
sources: CurveSet | Curve | Iterable[CurveSet | Curve],
variable_names: Iterable[str] = (),
labels: Iterable[str] = (),
directory_path: str | Path = "",
save: bool = False,
show: bool = True,
file_name: str | Path = "",
fig: Figure | None = None,
) -> Figure
Superpose curves on a single figure.
The curves are given either individually, or bundled into the
:class:.CurveSet of a figure, which also carries their style.
This handles the two kinds of superposition:
- the traces of a single :class:
.CurveSet, i.e. several ordinate variables of a single model result, styled by its plot specification, - the same curve coming from several results, e.g. to compare the runs of a
database, in which case
labelsidentifies each result.
Parameters:
-
sources(CurveSet | Curve | Iterable[CurveSet | Curve]) –The curve sets or curves to draw. They shall all share the same abscissa variable.
-
variable_names(Iterable[str], default:()) –The names of the ordinate variables to draw. All of them by default.
-
labels(Iterable[str], default:()) –The label of each source, used as a legend prefix.
-
directory_path(str | Path, default:'') –The path where to save the figure.
-
save(bool, default:False) –Whether to save the figure.
-
show(bool, default:True) –Whether to show the figure.
-
file_name(str | Path, default:'') –The name of the file to save the figure to.
-
fig(Figure | None, default:None) –A figure to draw on. A new one is created when
None.
Returns:
-
Figure–The figure.
Raises:
-
ValueError–When the sources do not share the same abscissa variable.
Source code in src\vimseo\utilities\plotting_utils.py
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 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |