Plotly Plotter¤
MilestonesModel
pydantic-model
¤
Bases: BaseModel
Model for the milestone labels and their positions on the x axis.
Ensures that milestone labels exist, are properly structured, and valid.
Fields:
-
milestone_labels(dict[str, int])
Validators:
Source code in lexos/rolling_windows/plotters/plotly_plotter.py
check_empty_dict()
pydantic-validator
¤
Check that the milestone_labels dict is not empty.
Source code in lexos/rolling_windows/plotters/plotly_plotter.py
PlotlyPlotter
pydantic-model
¤
Bases: BasePlotter
Plotter using Plotly.
Config:
arbitrary_types_allowed:Truevalidate_assignment:True
Fields:
-
df(DataFrame) -
width(Optional[int]) -
height(Optional[int]) -
title(Optional[dict | str]) -
xlabel(Optional[str]) -
ylabel(Optional[str]) -
line_color(Optional[list[str] | str]) -
showlegend(Optional[bool]) -
titlepad(Optional[float]) -
show_milestones(Optional[bool]) -
milestone_marker_style(Optional[dict]) -
show_milestone_labels(Optional[bool]) -
milestone_labels(Optional[dict[str, int]]) -
milestone_label_rotation(Optional[float]) -
milestone_label_style(Optional[dict]) -
fig(Optional[Figure])
Validators:
Source code in lexos/rolling_windows/plotters/plotly_plotter.py
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 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 | |
df: pd.DataFrame
pydantic-field
¤
A dataframe containing the data to plot.
height: Optional[int] = 450
pydantic-field
¤
The height of the plot in pixels. Note that if you change the height, you will need to adjust the titelpad manually to show the title above milestone labels.
line_color: Optional[list[str] | str] = px.colors.qualitative.Plotly
pydantic-field
¤
The colour pattern to use for lines on the plot.
metadata: dict
property
¤
Return metadata about the object.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing metadata about the object. |
milestone_label_rotation: Optional[float] = 0.0
pydantic-field
¤
The number of degrees clockwise to rotate the milestone labels (maximum 90).
milestone_label_style: Optional[dict] = {'size': 10.0, 'family': 'Open Sans, verdana, arial, sans-serif', 'color': 'teal'}
pydantic-field
¤
A dict containing the styling information for the milestone labels. For valid properties, see https://plotly.com/python/reference/layout/annotations/#layout-annotations-items-annotation-font.
milestone_labels: Optional[dict[str, int]] = None
pydantic-field
¤
A dict containing the milestone labels and their values on the x-axis.
milestone_marker_style: Optional[dict] = {'width': 1, 'color': 'teal'}
pydantic-field
¤
A dict containing the styles to apply to the milestone marker. For valid properties, see https://plotly.com/python-api-reference/generated/plotly.graph_objects.layout.shape.html#plotly.graph_objects.layout.shape.Line.
show_milestone_labels: Optional[bool] = False
pydantic-field
¤
Whether to show the milestone labels.
show_milestones: Optional[bool] = False
pydantic-field
¤
Whether to show the milestone markers.
showlegend: Optional[bool] = True
pydantic-field
¤
Show the legend.
title: Optional[dict | str] = 'Rolling Windows Plot'
pydantic-field
¤
The title to use for the plot. It can be styled with a dict containing any of the keywords listed at https://plotly.com/python/reference/layout/#layout-title.
titlepad: Optional[float] = None
pydantic-field
¤
The margin in pixels between the title and the top of the plot.
width: Optional[int] = 700
pydantic-field
¤
The width of the plot in pixels.
xlabel: Optional[str] = 'Token Count'
pydantic-field
¤
The text to display along the x axis.
ylabel: Optional[str] = 'Average Frequency'
pydantic-field
¤
The text to display along the y axis.
__init__(**kwargs) -> None
¤
Initialise the instance with arbitrary keywords.
Source code in lexos/rolling_windows/plotters/plotly_plotter.py
is_valid_rotation(value: float) -> float
pydantic-validator
¤
Ensure that the milestone label rotation is between 0 and 90 degrees.
Source code in lexos/rolling_windows/plotters/plotly_plotter.py
plot(show: Optional[bool] = True, config: Optional[dict] = None, **kwargs: Any) -> None
¤
Initialise object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show
|
Optional[bool]
|
Whether to display the plot immediately. |
True
|
config
|
Optional[dict]
|
A dictionary supply Plotly configuration values. |
None
|
**kwargs
|
Any
|
Additional keyword arguments accepted by plotly.express.line. |
{}
|
Source code in lexos/rolling_windows/plotters/plotly_plotter.py
save(path: Path | str, **kwargs: Any) -> None
¤
Save the plot to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str
|
The path to the file to save. |
required |
**kwargs
|
Any
|
Additional keyword arguments accepted by plotly.io.write_html or plotly.io.write_image. |
{}
|
Source code in lexos/rolling_windows/plotters/plotly_plotter.py
show(config: Optional[dict] = None) -> None
¤
Display a plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Optional[dict]
|
A dictionary supply Plotly configuration values. |
None
|