Matplotlib
pytao.plotting.mpl
Classes
pytao.plotting.mpl.MatplotlibGraphManager
MatplotlibGraphManager(tao)
Bases: GraphManager
Matplotlib backend graph manager.
Source code in pytao/plotting/plot.py
1250 1251 1252 1253 | |
Methods:
plot(template, *, region_name=None, include_layout=True, tight_layout=True, width=None, height=None, layout_height=None, figsize=None, share_x=True, xlim=None, ylim=None, save=None, settings=None, curves=None, axes=None, ix_uni=None)
Plot a graph with Matplotlib.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
str
|
Graph template name. |
required |
region_name
|
str
|
Graph region name. |
None
|
include_layout
|
bool
|
Include a layout plot at the bottom, if not already placed and if appropriate (i.e., another plot uses longitudinal coordinates on the x-axis). |
True
|
tight_layout
|
bool
|
Apply a tight layout with matplotlib. |
True
|
figsize
|
(float, float)
|
Figure size. Alternative to specifying |
None
|
width
|
float
|
Width of the whole plot. |
None
|
height
|
float
|
Height of the whole plot. |
None
|
layout_height
|
float
|
Normalized height of the layout plot - assuming regular plots are
of height 1. Default is 0.5 which is configurable with |
None
|
share_x
|
bool
|
Share x-axes for all plots. |
True
|
xlim
|
(float, float)
|
X axis limits. |
None
|
ylim
|
(float, float)
|
Y axis limits. |
None
|
save
|
Path or str
|
Save the plot to the given filename. |
None
|
curves
|
Dict[int, TaoCurveSettings]
|
Dictionary of curve index to curve settings. These settings will be applied to the placed graph prior to plotting. |
None
|
settings
|
TaoGraphSettings
|
Graph customization settings. |
None
|
ix_uni
|
int
|
Plot data from this universe. |
None
|
Returns:
| Type | Description |
|---|---|
list of graphs
|
List of plotted graphs. |
Figure
|
To gain access to the resulting plot objects, use the backend's
|
List[Axes]
|
|
Source code in pytao/plotting/mpl.py
801 802 803 804 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 | |
plot_ele_methods(data, *, columns=None, show_names=True, show_csr_ds_step=None, include_layout=True, lane_height=0.8, figsize=None, width=None, height=None, layout_height=None, ax=None, save=None)
Plot element method settings as categorical lanes along the beamline.
Each method (e.g., tracking_method) becomes a horizontal lane, with
each element drawn as a block spanning its longitudinal extent, colored
by the method value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ElementMethodsPlotData
|
Per-element method data, gathered via
|
required |
columns
|
sequence of str
|
Method columns to plot, in order. Defaults to all categorical columns with data for the selected elements. |
None
|
show_names
|
bool
|
Label method transitions with the element names before and after the transition point. |
True
|
show_csr_ds_step
|
bool
|
Add a subplot of |
None
|
include_layout
|
bool
|
Include a lattice layout plot at the bottom. |
True
|
lane_height
|
float
|
Height of each lane's blocks, where lanes are spaced 1.0 apart. |
0.8
|
figsize
|
(float, float)
|
Figure size. Takes precedence over |
None
|
width
|
float
|
Width of the whole plot. |
None
|
height
|
float
|
Height of the whole plot. |
None
|
layout_height
|
float
|
Normalized height of the layout plot - assuming the lane plot is
of height 1. Defaults to about half the height of a single lane
( |
None
|
ax
|
Axes
|
The axes to place the lanes in. Only supported with
|
None
|
save
|
Path or str
|
Save the plot to the given filename. |
None
|
Returns:
| Type | Description |
|---|---|
ElementMethodsPlotData
|
|
Figure
|
|
list of matplotlib.axes.Axes
|
|
Source code in pytao/plotting/mpl.py
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 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 | |
plot_field(ele_id, *, colormap=None, radius=0.015, num_points=100, figsize=None, width=4, height=4, x_scale=1000.0, ax=None, save=None)
Plot field information for a given element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ele_id
|
str
|
Element ID. |
required |
colormap
|
str
|
Colormap for the plot. Matplotlib defaults to "PRGn_r", and bokeh defaults to "". |
None
|
radius
|
float
|
Radius. |
0.015
|
num_points
|
int
|
Number of data points. |
100
|
ax
|
Axes
|
The axes to place the plot in. |
None
|
save
|
Path or str
|
Save the plot to the given filename. |
None
|
Source code in pytao/plotting/mpl.py
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 986 987 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 | |
plot_grid(templates, grid, *, include_layout=False, figsize=None, tight_layout=True, share_x='col', layout_height=None, width=None, height=None, xlim=None, ylim=None, curves=None, settings=None, save=None, axes=None, ix_uni=None)
Plot graphs on a grid with Matplotlib.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
templates
|
list of str
|
Graph template names. |
required |
grid
|
(nrows, ncols)
|
Grid the provided graphs into this many rows and columns. |
required |
include_layout
|
bool
|
Include a layout plot at the bottom of each column. |
False
|
tight_layout
|
bool
|
Apply a tight layout with matplotlib. |
True
|
figsize
|
(float, float)
|
Figure size. Alternative to specifying |
None
|
width
|
float
|
Width of the whole plot. |
None
|
height
|
float
|
Height of the whole plot. |
None
|
layout_height
|
int
|
Normalized height of the layout plot - assuming regular plots are
of height 1. Default is 0.5 which is configurable with |
None
|
share_x
|
(bool, 'row', 'col', 'all')
|
Share all x-axes ( |
"col"
|
xlim
|
list of (float, float)
|
X axis limits for each graph. |
None
|
ylim
|
list of (float, float)
|
Y axis limits for each graph. |
None
|
curves
|
list of Dict[int, TaoCurveSettings]
|
One dictionary per graph, with each dictionary mapping the curve index to curve settings. These settings will be applied to the placed graphs prior to plotting. |
None
|
settings
|
list of TaoGraphSettings
|
Graph customization settings, per graph. |
None
|
save
|
Path or str
|
Save the plot to the given filename. |
None
|
ix_uni
|
int
|
Plot data from this universe for every graph in the grid. |
None
|
Returns:
| Type | Description |
|---|---|
list of graphs
|
List of plotted graphs. |
Figure
|
To gain access to the resulting plot objects, use the backend's
|
List[List[Axes]]
|
Gridded axes, accessible with |
Source code in pytao/plotting/mpl.py
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 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 | |
Functions:
pytao.plotting.mpl.set_defaults
set_defaults(layout_height=None, colormap=None, line_width_scale=None, floor_line_width_scale=None, figsize=None, width=None, height=None, dpi=None)
Set default values for Matplotlib plot settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout_height
|
float
|
Height of the layout. Default is 0.5. |
None
|
colormap
|
str
|
Colormap to use for plotting. Default is "PRGn_r". |
None
|
line_width_scale
|
float
|
Scale factor for line widths, excluding floor plan lines. Default is 0.5. |
None
|
floor_line_width_scale
|
float
|
Scale factor for floor plan line widths. Default is 0.5. |
None
|
figsize
|
tuple of float
|
Size of the figure (width, height). Default is as-configured in matplotlib rcParams. |
None
|
width
|
float
|
Width of the figure in inches. Default is as-configured in matplotlib rcParams. |
None
|
height
|
float
|
Height of the figure in inches. Default is as-configured in matplotlib rcParams. |
None
|
dpi
|
int
|
Dots per inch for the figure. Default is as-configured in matplotlib rcParams. |
None
|
Source code in pytao/plotting/mpl.py
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 | |
pytao.plotting.mpl.setup_matplotlib_axis
setup_matplotlib_axis(graph, ax)
Configure limits, title, and basic info for the given axes.
Source code in pytao/plotting/mpl.py
166 167 168 169 170 171 172 173 174 175 176 177 | |