File: LinearEnumerateFunction.py

package info (click to toggle)
openturns 1.26-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,708 kB
  • sloc: cpp: 261,605; python: 67,030; ansic: 4,378; javascript: 406; sh: 185; xml: 164; makefile: 101
file content (169 lines) | stat: -rw-r--r-- 2,858 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import matplotlib.pyplot as plt

# Create the figure
plt.figure(1, figsize=(4, 4))
ax = plt.subplot(111)

# Create the points
ax.plot(
    [0, 0, 1, 0, 1, 2, 3, 2, 1, 0], [0, 1, 0, 2, 1, 0, 0, 1, 2, 3], "o", markersize=9
)

# Create the arrows
ax.annotate(
    "",
    xy=(0.97, 0),
    xycoords="data",
    xytext=(0, 0),
    textcoords="data",
    arrowprops=dict(
        arrowstyle="-|>",
        linestyle="dashed",
        mutation_scale=15,
        connectionstyle="arc3",
        color="black",
    ),
)

ax.arrow(
    1,
    0,
    -0.97,
    0.97,
    head_width=0.08,
    head_length=0.08,
    fc="k",
    ec="k",
    length_includes_head=True,
    linestyle="dashed",
)
ax.arrow(
    0,
    1,
    1.97,
    -0.97,
    head_width=0.08,
    head_length=0.08,
    fc="k",
    ec="k",
    length_includes_head=True,
    linestyle="dashed",
)
ax.arrow(
    2,
    0,
    -1.97,
    1.97,
    head_width=0.08,
    head_length=0.08,
    fc="k",
    ec="k",
    length_includes_head=True,
    linestyle="dashed",
)
ax.arrow(
    0,
    2,
    2.97,
    -1.97,
    head_width=0.08,
    head_length=0.08,
    fc="k",
    ec="k",
    length_includes_head=True,
    linestyle="dashed",
)
ax.arrow(
    3,
    0,
    -2.97,
    2.97,
    head_width=0.08,
    head_length=0.08,
    fc="k",
    ec="k",
    length_includes_head=True,
    linestyle="dashed",
)
ax.arrow(
    0,
    3,
    1.97,
    -0.97,
    head_width=0.08,
    head_length=0.08,
    fc="k",
    ec="k",
    length_includes_head=True,
    linestyle="dashed",
)

# Annotate points
ax.annotate(
    "4",
    xy=(1, 1),
    xycoords="data",
    xytext=(-20, -5),
    textcoords="offset points",
    fontsize=16,
)

ax.annotate(
    "7",
    xy=(2, 1),
    xycoords="data",
    xytext=(+15, +0),
    textcoords="offset points",
    fontsize=16,
)

ax.annotate(
    "8",
    xy=(1, 2),
    xycoords="data",
    xytext=(+15, +0),
    textcoords="offset points",
    fontsize=16,
)

# Add labels
ax.annotate(
    r"$\tau_1$",
    xy=(1, 0),
    xytext=(10, 10),
    ha="left",
    va="center",
    xycoords="axes fraction",
    textcoords="offset points",
    fontsize=20,
)

ax.annotate(
    r"$\tau_2$",
    xy=(0, 1),
    xytext=(0, 10),
    ha="left",
    va="center",
    xycoords="axes fraction",
    textcoords="offset points",
    fontsize=20,
)

# Hide spines
ax.spines["right"].set_color("none")
ax.spines["top"].set_color("none")

# Set spines's position
ax.xaxis.set_ticks_position("bottom")
ax.spines["bottom"].set_position(("data", 0))
ax.yaxis.set_ticks_position("left")
ax.spines["left"].set_position(("data", 0))

# Add labels
plt.xticks([-0.1] + list(range(4)) + [3.2])
ax.set_xticklabels(("", "$0$", "$1$", "$3$", "$6$", ""), fontsize=20)
plt.yticks([-0.1] + list(range(4)) + [3.2])
ax.set_yticklabels(("", "", "$2$", "$5$", "$9$", ""), fontsize=20)

# Show the figure
plt.show()