Skip to content

text

Text-based report panel helpers.

plot_info(axis, data, mfile, scan)

Function to plot data in written form on a matplotlib plot.

Parameters:

Name Type Description Default
axis Axes

axis object to plot to

required
data

plot information

required
mfile MFile

MFILE

required
scan int

scan number to use

required
Source code in process/core/io/plot/summary/reporting/text.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
def plot_info(axis: plt.Axes, data, mfile: MFile, scan: int):
    """Function to plot data in written form on a matplotlib plot.

    Parameters
    ----------
    axis :
        axis object to plot to
    data :
        plot information
    mfile :
        MFILE
    scan :
        scan number to use
    """
    eqpos = 0.75
    for i in range(len(data)):
        colorflag = "black"
        if mfile.data[data[i][0]].exists:
            if mfile.data[data[i][0]].var_flag == "ITV":
                colorflag = "red"
            elif mfile.data[data[i][0]].var_flag == "OP":
                colorflag = "blue"
        axis.text(0, -i, data[i][1], color=colorflag, ha="left", va="center")
        if isinstance(data[i][0], str):
            if not data[i][0]:
                axis.text(eqpos, -i, "\n", ha="left", va="center")
            elif data[i][0][0] == "#":
                axis.text(
                    -0.05,
                    -i,
                    f"{data[i][0][1:]}\n",
                    ha="left",
                    va="center",
                )
            elif data[i][0][0] == "!":
                value = data[i][0][1:].replace('"', "")
                axis.text(
                    0.4,
                    -i,
                    f"-->  {value} {data[i][2]}",
                    ha="left",
                    va="center",
                )
            elif mfile.data[data[i][0]].exists:
                dat = mfile.get(data[i][0], scan=scan)
                if isinstance(dat, str):
                    value = dat
                else:
                    value = f"{mfile.get(data[i][0], scan=scan):.4g}"
                if "alpha" in data[i][0]:
                    value = str(float(value) + 1.0)
                    axis.text(
                        eqpos,
                        -i,
                        f"= {value} {data[i][2]}",
                        color=colorflag,
                        ha="left",
                        va="center",
                    )
            else:
                mfile.get(data[i][0], scan=-1)
                axis.text(
                    eqpos,
                    -i,
                    "= ERROR! Var missing",
                    color=colorflag,
                    ha="left",
                    va="center",
                )
        else:
            dat = data[i][0]
            value = dat if isinstance(dat, str) else f"{data[i][0]:.4g}"
            axis.text(
                eqpos,
                -i,
                f"= {value} {data[i][2]}",
                color=colorflag,
                ha="left",
                va="center",
            )