Elements
The specific elements on the calendar plot.
Includes x-axis, y-axis, and their settings, as well as the calendar events.
CalendarEvent
dataclass
Something on the calendar.
Plots rectangles on matplotlib axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
day
|
int
|
The day of the week. 0 is Monday. |
required |
start
|
float
|
The start hour of the event. |
required |
end
|
float | None
|
The end hour of the event. |
None
|
duration
|
float | None
|
The duration of the event. Only used if end is None. |
None
|
days
|
int
|
The number of days the event spans. Default is 1. |
1
|
Examples:
Plot event from calendar data
calendar_data = CalendarData(day=0, start=0, end=2.5)
event = CalendarEvent.from_calendar_data(calendar_data=calendar_data, cmap=...)
event.plot(ax=ax)
Plot a single calendar event from vocab
Source code in latent_calendar/plot/elements.py
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 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
|
from_vocab(vocab, duration=60.0)
classmethod
Constructor from vocab string in order to plot on an axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vocab
|
str
|
The vocab string. |
required |
duration
|
float
|
The duration of the event. |
60.0
|
Example
Plot on an axis
Plot a two and half hour window
Source code in latent_calendar/plot/elements.py
plot(ax, monday_start=True, lw=0.1, fill=True, linestyle=None, fillcolor=None, alpha=None, **kwargs)
Put the CalendarEvent instance onto an axis.
Options for kwargs here.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax
|
Axes
|
Axis to plot on |
required |
monday_start
|
bool
|
Whether to start the week on Monday or Sunday. |
True
|
lw
|
float
|
The line width of the event. |
0.1
|
fill
|
bool
|
Whether to fill the event. |
True
|
linestyle
|
The line style of the event. |
None
|
|
fillcolor
|
The color of the event. |
None
|
|
alpha
|
The alpha of the event. |
None
|
|
kwargs
|
Addtional kwargs for the Patch instances or to override. |
{}
|
Source code in latent_calendar/plot/elements.py
separate_events()
Return list of events that represent the one event across different days.
Examples:
A single event that goes from 23:00 to 01:00 will be split into two events.
Source code in latent_calendar/plot/elements.py
DayLabeler
dataclass
Day of the week axis.
This is typically the x-axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
day_start
|
int
|
The day to start the plot at. |
0
|
days_of_week
|
list[str]
|
The names of the days of the week. |
create_default_days()
|
rotation
|
float | None
|
The rotation of the day labels. |
45
|
display
|
bool
|
Whether to display the day labels. |
True
|
Source code in latent_calendar/plot/elements.py
day_labels: list[str]
property
What is added to the plot. If this is display, empty ticks.
create_labels(ax, axis='x')
Create the labels for the plot.
Source code in latent_calendar/plot/elements.py
DisplaySettings
dataclass
Small wrapper to hold the display settings in the plots.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
bool
|
Whether to x axis the plot. |
True
|
y
|
bool
|
Whether to y axis the plot. |
True
|
Source code in latent_calendar/plot/elements.py
GridLines
dataclass
Grid lines between the calendar for the plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dow
|
bool
|
Whether to add day of week grid lines. |
False
|
hour
|
bool
|
Whether to add hour grid lines. |
False
|
color
|
str
|
The color of the grid lines. |
'black'
|
linestyle
|
str
|
The style of the grid lines. |
'--'
|
alpha
|
float
|
The alpha of the grid lines. |
0.2
|
Source code in latent_calendar/plot/elements.py
TimeLabeler
dataclass
This is time of day and all its settings in the plot.
This is typically the y-axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hour_formatter
|
HourFormatter
|
The formatter for the hour labels. |
HourFormatter()
|
start
|
int
|
The hour to start the plot at. |
0
|
stride
|
int
|
The number of hours to skip between ticks. |
2
|
display
|
bool
|
Whether to display the hour labels. |
True
|
rotation
|
float | None
|
The rotation of the hour labels. |
0
|
Source code in latent_calendar/plot/elements.py
create_labels(ax, axis='y')
Create the hour labels on the plot ax.