Plots¶
circumplex.visualization.plots
¶
Matplotlib-based plotting functions for SSM results.
| FUNCTION | DESCRIPTION |
|---|---|
plot_circle |
Plot SSM profiles on a circumplex circle. |
plot_curve |
Plot SSM fitted curves with observed scores. |
plot_contrast |
Plot SSM parameter contrasts with confidence intervals. |
plot_circle
¶
plot_circle(results_df: DataFrame, angles: list[float] | ndarray, *, profile_indices: list[int] | None = None, amax: float | None = None, angle_labels: list[str] | None = None, colors: str | list[str] | None = 'Set2', fontsize: float = 12, drop_lowfit: bool = False, figsize: tuple[float, float] = (8, 8), title: str | None = None) -> Figure
Plot SSM profiles on a circumplex circle.
Creates a circular plot showing amplitude and displacement of SSM profiles, with arc bars representing confidence intervals. Automatically handles both single and multiple profiles.
| PARAMETER | DESCRIPTION |
|---|---|
results_df
|
DataFrame with SSM results. Must contain columns: - Label: str, profile name - e_est, x_est, y_est, a_est, d_est: float, parameter estimates - e_lci, x_lci, ..., d_uci: float, confidence intervals - fit_est: float, model fit (0-1)
TYPE:
|
angles
|
Angular positions of scales in degrees (e.g., [90, 135, 180, 225, 270, 315, 360, 45]). |
profile_indices
|
Which rows of results_df to plot. If None, plots all profiles. |
amax
|
Maximum amplitude for scaling. If None, auto-computed using pretty_max().
TYPE:
|
angle_labels
|
Labels for each angle. If None, shows degree symbols (e.g., "90°"). Pass empty strings to hide labels. |
colors
|
Colors for profiles. Can be: - Seaborn palette name: "Set2", "husl", "deep", etc. - List of color specifications: ['red', 'blue'] or ['#FF0000', '#0000FF'] - None: single blue color with no legend |
fontsize
|
Base font size in points.
TYPE:
|
drop_lowfit
|
If True, omit profiles with fit < 0.70. If False, show with dashed borders.
TYPE:
|
figsize
|
Figure size in inches (width, height). |
title
|
Title for the plot. If None, no title is added.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Figure
|
Matplotlib Figure object. |
Examples:
Plot all profiles from an SSM analysis:
>>> from circumplex import ssm_analyze
>>> results = ssm_analyze(data, scales=list(range(8)))
>>> fig = plot_circle(results.results, results.details.angles)
>>> fig.savefig('profiles.png')
Plot specific profiles with custom styling:
>>> fig = plot_circle(
... results.results,
... results.details.angles,
... profile_indices=[0, 1],
... colors="husl",
... fontsize=14,
... figsize=(10, 10),
... )
Use custom colors:
>>> fig = plot_circle(
... results.results,
... results.details.angles,
... colors=['red', 'blue', 'green'],
... )
See Also
plot_curve :
Plot SSM fitted curves with observed scores
plot_contrast :
Plot SSM parameter contrasts
Source code in src/circumplex/visualization/plots.py
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 555 556 557 558 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 | |
plot_curve
¶
plot_curve(results_df: DataFrame, scores_df: DataFrame, angles: list[float] | ndarray, *, profile_indices: list[int] | None = None, angle_labels: list[str] | None = None, c_scores: str = 'red', c_fit: str = 'black', base_size: float = 11, drop_lowfit: bool = False, figsize: tuple[float, float] | None = None, incl_pred: bool = True, incl_fit: bool = False, incl_disp: bool = False, incl_amp: bool = False, incl_elev: bool = False) -> Figure
Plot SSM fitted curves with observed scores.
Creates a faceted plot showing the fitted cosine curve overlaid on the observed circumplex scale scores. Each profile is shown in a separate subplot.
| PARAMETER | DESCRIPTION |
|---|---|
results_df
|
DataFrame with SSM results. Must contain columns: - Label: str, profile name - e_est, a_est, d_est: float, parameter estimates - fit_est: float, model fit (0-1)
TYPE:
|
scores_df
|
DataFrame with observed circumplex scores. Must have columns: - Label: str, profile name (matching results_df) - Scale columns: float, one column per circumplex scale
TYPE:
|
angles
|
Angular positions of scales in degrees, matching score column order. |
profile_indices
|
Which rows to plot. If None, plots all profiles. |
angle_labels
|
Labels for each angle on x-axis. If None, shows degree symbols (e.g., "90°"). |
c_scores
|
Color for observed scores (points and lines).
TYPE:
|
c_fit
|
Color for fitted curve.
TYPE:
|
base_size
|
Base font size in points for labels and text.
TYPE:
|
drop_lowfit
|
If True, omit profiles with fit < 0.70. If False, show with dashed curves.
TYPE:
|
figsize
|
Figure size in inches (width, height). If None, auto-computed based on number of profiles. |
| RETURNS | DESCRIPTION |
|---|---|
Figure
|
Matplotlib Figure object. |
Examples:
Plot curves from an SSM analysis:
>>> from circumplex import ssm_analyze
>>> results = ssm_analyze(data, scales=list(range(8)))
>>> fig = plot_curve(results.results, results.scores, results.details.angles)
>>> fig.savefig('curves.png')
Use custom angle labels:
>>> fig = plot_curve(
... results.results,
... results.scores,
... results.details.angles,
... angle_labels=['PA', 'BC', 'DE', 'FG', 'HI', 'JK', 'LM', 'NO'],
... )
See Also
plot_circle :
Plot SSM profiles on a circumplex circle
plot_contrast :
Plot SSM parameter contrasts
Source code in src/circumplex/visualization/plots.py
805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | |
plot_contrast
¶
plot_contrast(results_df: DataFrame, *, drop_xy: bool = False, sig_color: str = '#fc8d62', ns_color: str = 'white', linewidth: float = 1.25, fontsize: float = 12, figsize: tuple[float, float] | None = None) -> Figure
Plot SSM parameter contrasts with confidence intervals.
Creates a faceted plot showing the difference between two profiles for each SSM parameter (elevation, x-value, y-value, amplitude, displacement). Points are colored based on statistical significance (whether CI includes zero).
This function requires results from a contrast analysis (e.g., comparing two groups or measures).
| PARAMETER | DESCRIPTION |
|---|---|
results_df
|
DataFrame with SSM contrast results. Must contain the contrast row (typically the last row) with columns: - Label: str, contrast label (e.g., "Group 1 - Group 2") - e_est, x_est, y_est, a_est, d_est: float, parameter differences - e_lci, x_lci, ..., d_uci: float, confidence intervals
TYPE:
|
drop_xy
|
Whether to omit x-value and y-value parameters from the plot. This can simplify the plot when only interested in elevation, amplitude, and displacement (default = False).
TYPE:
|
sig_color
|
Color for significant contrasts (CI excludes zero).
TYPE:
|
ns_color
|
Color for non-significant contrasts (CI includes zero).
TYPE:
|
linewidth
|
Width of error bars and point outlines in points.
TYPE:
|
fontsize
|
Base font size in points for labels and text.
TYPE:
|
figsize
|
Figure size in inches (width, height). If None, uses (10, 4) for all parameters or (7, 4) if drop_xy=True. |
| RETURNS | DESCRIPTION |
|---|---|
Figure
|
Matplotlib Figure object. |
Examples:
Plot contrasts from an SSM analysis:
>>> from circumplex import ssm_analyze
>>> results = ssm_analyze(
... data, scales=list(range(8)),
... grouping='condition', contrast=True
... )
>>> fig = plot_contrast(results.results)
>>> fig.savefig('contrasts.png')
Drop x and y parameters for simpler plot:
Use custom colors:
See Also
plot_circle :
Plot SSM profiles on a circumplex circle
plot_curve :
Plot SSM fitted curves with observed scores
Source code in src/circumplex/visualization/plots.py
988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 | |