-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfigures.py
executable file
·111 lines (102 loc) · 2.98 KB
/
figures.py
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
#!/usr/bin/env python
#
from numpy import *
from pylab import *
def initFigure(w, h):
figure(figsize=(w, h), dpi=80)
subplot(1, 1, 1)
tight_layout(pad=4.00)
font = {'size' : 16}
matplotlib.rc('font', **font)
def setSpines():
ax = gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
def monotonicity_math(path):
initFigure(8, 5)
setSpines()
# Plot a monotone and antitone function
X = linspace(0, 12, 256, endpoint=True)
EmX = exp(-X)
EX = exp(X) - 1
plot(X, EmX, color='blue', linewidth=3.0, linestyle='-', label='$e^{-x}$')
plot(X, EX, color='green', linewidth=3.0, linestyle=':', label='$e^x - 1$')
# Label the axes
xlabel('$x$')
xlim(-0.1, 2.1)
ylim(-0.1, 5.1)
# Create a legend
legend()
# Save
savefig(path)
def monotonicity_lex_all(path):
initFigure(8, 5)
setSpines()
# Plot 'all' and 'some'
plot([0, 3, 6, 7, 7, 9, 12],
[1, 1, 1, 1, 0, 0, 0], color='blue', linewidth=3.0, linestyle='-', label='all $x$ drink milk')
plot([0, 3, 6, 8, 8, 9, 12],
[0, 0, 0, 0, 1, 1, 1], color='green', linewidth=3.0, linestyle=':', label='some $x$ bark')
# Label the axes
# xlabel('Denotation of word $x$')
xlim(-1.0, 13.0)
xticks([0, 3, 6, 9, 12],
['$x=$ Felix', 'kitten', 'cat', 'animal', 'thing'])
# ylabel('Truth Value of Sentence')
ylim(-0.1, 1.7)
yticks([0, 1], ['False', 'True'])
# Create a legend
legend()
# Save
savefig(path)
def monotonicity_lex_meronymy(path):
initFigure(8, 5)
setSpines()
# Plot 'is pretty' and 'was born in'
plot([0, 3, 5, 5, 6, 9, 12],
[0, 0, 0, 1, 1, 1, 1], color='blue', linewidth=3.0, linestyle='-', label='Obama was born in $x$')
plot([0, 2, 2, 3, 4, 4, 6, 9, 12],
[0, 0, 1, 1, 1, 0, 0, 0, 0], color='green', linewidth=3.0, linestyle=':', label='$x$ is an island')
# Label the axes
# xlabel('Denotation of word $x$')
xlim(-1.0, 13.0)
xticks([0, 3, 6, 9, 12],
['$x=$ Hilo', 'Big Island', 'Hawaii', 'USA', 'North America'])
# ylabel('Truth Value of Sentence')
ylim(-0.1, 1.7)
yticks([0, 1], ['False', 'True'])
# Create a legend
legend()
# Save
savefig(path)
def denotation_barks(path):
initFigure(8, 5)
setSpines()
# Plot 'is pretty' and 'was born in'
scatter([0, 3, 6, 9, 12],
[1, 0, 1, 0, 0])
# Label the axes
# xlabel('Denotation of word $x$')
xlim(-1.0, 13.0)
xticks([0, 3, 6, 9, 12],
['$x=$ [[dog]]',
'[[cat]]',
'[[poodle]]',
'[[human]]',
'[[Bill]]'
])
# ylabel('Truth Value of Sentence')
ylim(-0.1, 1.7)
yticks([0, 1], ['False', 'True'])
# Create a legend
legend()
# Save
savefig(path)
if __name__ == "__main__":
monotonicity_lex_all('img/monotonicity_lex_all.pdf')
monotonicity_math('img/monotonicity_math.pdf')
monotonicity_lex_meronymy('img/monotonicity_lex_meronymy.pdf')
denotation_barks('img/denotations_barks.pdf')
# show()