plot_study
This module provides functions to create and customize study plots, including heatmaps and 3D volume renderings.
Functions:
| Name | Description |
|---|---|
_set_style |
|
_add_text_annotation |
|
_smooth |
|
_mask |
|
_add_contours |
|
_add_diagonal_lines |
|
add_QR_code |
|
_set_labels |
|
plot_heatmap |
|
plot_3D |
|
add_QR_code(fig, link, position_qr='top-right')
Adds a QR code pointing to the given link to the figure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fig
|
Figure
|
The figure to add the QR code to. |
required |
link
|
str
|
The link to encode in the QR code. |
required |
Returns:
| Type | Description |
|---|---|
Figure
|
plt.Figure: The figure with the QR code. |
Source code in study_da/plot/plot_study.py
plot_3D(dataframe_data, x_variable, y_variable, z_variable, color_variable, xlabel=None, ylabel=None, z_label=None, title='', vmin=4.5, vmax=7.5, surface_count=30, opacity=0.2, figsize=(1000, 1000), colormap='RdBu', colorbar_title_text='Minimum DA (σ)', display_colormap=False, output_path='output.png', output_path_html='output.html', display_plot=True, dark_theme=False)
Plots a 3D volume rendering from the given dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe_data
|
DataFrame
|
The dataframe containing the data to plot. |
required |
x_variable
|
str
|
The variable to plot on the x-axis. |
required |
y_variable
|
str
|
The variable to plot on the y-axis. |
required |
z_variable
|
str
|
The variable to plot on the z-axis. |
required |
color_variable
|
str
|
The variable to use for the color scale. |
required |
xlabel
|
Optional[str]
|
The label for the x-axis. Defaults to None. |
None
|
ylabel
|
Optional[str]
|
The label for the y-axis. Defaults to None. |
None
|
z_label
|
Optional[str]
|
The label for the z-axis. Defaults to None. |
None
|
title
|
str
|
The title of the plot. Defaults to "". |
''
|
vmin
|
float
|
The minimum value for the color scale. Defaults to 4.5. |
4.5
|
vmax
|
float
|
The maximum value for the color scale. Defaults to 7.5. |
7.5
|
surface_count
|
int
|
The number of surfaces for volume rendering. Defaults to 30. |
30
|
opacity
|
float
|
The opacity of the volume rendering. Defaults to 0.2. |
0.2
|
figsize
|
tuple[float, float]
|
The size of the figure. Defaults to (1000, 1000). |
(1000, 1000)
|
colormap
|
str
|
The colormap to use. Defaults to "RdBu". |
'RdBu'
|
colorbar_title_text
|
str
|
The label for the colorbar. Defaults to "Minimum DA (σ)". |
'Minimum DA (σ)'
|
display_colormap
|
bool
|
Whether to display the colormap. Defaults to False. |
False
|
output_path
|
str
|
The path to save the plot image. Defaults to "output.png". |
'output.png'
|
output_path_html
|
str
|
The path to save the plot HTML. Defaults to "output.html". |
'output.html'
|
display_plot
|
bool
|
Whether to display the plot. Defaults to True. |
True
|
dark_theme
|
bool
|
Whether to use a dark theme. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
Any
|
go.Figure: The plotly figure object. |
Source code in study_da/plot/plot_study.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 | |
plot_heatmap(dataframe_data, horizontal_variable, vertical_variable, color_variable, link=None, position_qr='top-right', plot_contours=True, xlabel=None, ylabel=None, tick_interval=2, round_xticks=None, round_yticks=None, symmetric_missing=False, mask_lower_triangle=False, mask_upper_triangle=False, plot_diagonal_lines=True, shift_diagonal_lines=1, xaxis_ticks_on_top=True, title='', vmin=4.5, vmax=7.5, k_masking=-1, green_contour=6.0, min_level_contours=1, max_level_contours=15, delta_levels_contours=0.5, figsize=None, label_cbar='Minimum DA (' + '$\\sigma$' + ')', colormap='coolwarm_r', style='ggplot', output_path='output.png', display_plot=True, latex_fonts=True, vectorize=False, fill_missing_value_with=None, dpi=300)
Plots a heatmap from the given dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe_data
|
DataFrame
|
The dataframe containing the data to plot. |
required |
horizontal_variable
|
str
|
The variable to plot on the horizontal axis. |
required |
vertical_variable
|
str
|
The variable to plot on the vertical axis. |
required |
color_variable
|
str
|
The variable to use for the color scale. |
required |
link
|
Optional[str]
|
A link to encode in a QR code. Defaults to None. |
None
|
plot_contours
|
bool
|
Whether to plot contours. Defaults to True. |
True
|
xlabel
|
Optional[str]
|
The label for the x-axis. Defaults to None. |
None
|
ylabel
|
Optional[str]
|
The label for the y-axis. Defaults to None. |
None
|
tick_interval
|
int
|
The interval for the ticks. Defaults to 2. |
2
|
round_xticks
|
Optional[int]
|
The number of decimal places to round the x-ticks to. Defaults to None. |
None
|
round_yticks
|
Optional[int]
|
The number of decimal places to round the y-ticks to. Defaults to None. |
None
|
symmetric_missing
|
bool
|
Whether to make the matrix symmetric by replacing the lower triangle with the upper triangle. Defaults to False. |
False
|
mask_lower_triangle
|
bool
|
Whether to mask the lower triangle. Defaults to False. |
False
|
mask_upper_triangle
|
bool
|
Whether to mask the upper triangle. Defaults to False. |
False
|
plot_diagonal_lines
|
bool
|
Whether to plot diagonal lines. Defaults to True. |
True
|
shift_diagonal_lines
|
int
|
The shift for the diagonal lines. Defaults to 1. |
1
|
xaxis_ticks_on_top
|
bool
|
Whether to place the x-axis ticks on top. Defaults to True. |
True
|
title
|
str
|
The title of the plot. Defaults to "". |
''
|
vmin
|
float
|
The minimum value for the color scale. Defaults to 4.5. |
4.5
|
vmax
|
float
|
The maximum value for the color scale. Defaults to 7.5. |
7.5
|
k_masking
|
int
|
The k parameter for masking. Defaults to -1. |
-1
|
green_contour
|
Optional[float]
|
The value for the green contour line. Defaults to 6.0. |
6.0
|
min_level_contours
|
float
|
The minimum level for the contours. Defaults to 1. |
1
|
max_level_contours
|
float
|
The maximum level for the contours. Defaults to 15. |
15
|
delta_levels_contours
|
float
|
The delta between contour levels. Defaults to 0.5. |
0.5
|
figsize
|
Optional[tuple[float, float]]
|
The size of the figure. Defaults to None. |
None
|
label_cbar
|
str
|
The label for the colorbar. Defaults to "Minimum DA ($\sigma$)". |
'Minimum DA (' + '$\\sigma$' + ')'
|
colormap
|
str
|
The colormap to use. Defaults to "coolwarm_r". |
'coolwarm_r'
|
style
|
str
|
The style to use for the plot. Defaults to "ggplot". |
'ggplot'
|
output_path
|
str
|
The path to save the plot. Defaults to "output.pdf". |
'output.png'
|
display_plot
|
bool
|
Whether to display the plot. Defaults to True. |
True
|
latex_fonts
|
bool
|
Whether to use LaTeX fonts. Defaults to True. |
True
|
vectorize
|
bool
|
Whether to vectorize the plot. Defaults to False. |
False
|
fill_missing_value_with
|
Optional[str | float]
|
The value to fill missing values with. Can be a number or 'interpolate'. Defaults to None. |
None
|
dpi
|
int
|
The DPI for the plot. Defaults to 300. |
300
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
tuple[plt.Figure, plt.Axes]: The figure and axes of the plot. |
Source code in study_da/plot/plot_study.py
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 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | |