回答編集履歴

1

修正

2020/09/04 14:24

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -11,3 +11,119 @@
11
11
  simple_meaningful_word_cloud(data)
12
12
 
13
13
  ```
14
+
15
+
16
+
17
+ ## 追記
18
+
19
+
20
+
21
+ ↓を Jupyter Notebook 上にコピペして表示されませんか?
22
+
23
+
24
+
25
+ ```python
26
+
27
+ %matplotlib inline
28
+
29
+ from matplotlib import pyplot as plt
30
+
31
+
32
+
33
+ data = [
34
+
35
+ ("big data", 100, 15),
36
+
37
+ ("Hadoop", 95, 25),
38
+
39
+ ("Python", 75, 50),
40
+
41
+ ("R", 50, 40),
42
+
43
+ ("machine learning", 80, 20),
44
+
45
+ ("statistics", 20, 60),
46
+
47
+ ("data science", 60, 70),
48
+
49
+ ("analytics", 90, 3),
50
+
51
+ ("team player", 85, 85),
52
+
53
+ ("dynamic", 2, 90),
54
+
55
+ ("synergies", 70, 0),
56
+
57
+ ("actionable insights", 40, 30),
58
+
59
+ ("think out of the box", 45, 10),
60
+
61
+ ("self-starter", 30, 50),
62
+
63
+ ("customer focus", 65, 15),
64
+
65
+ ("thought leadership", 35, 35),
66
+
67
+ ]
68
+
69
+
70
+
71
+
72
+
73
+ def text_size(total):
74
+
75
+ """ custom text size settings """
76
+
77
+ return 8 + total / 200 * 20
78
+
79
+
80
+
81
+
82
+
83
+ def simple_meaningful_word_cloud(data):
84
+
85
+ fig, ax = plt.subplots(nrows=1)
86
+
87
+
88
+
89
+ for word, job_popularity, resume_popularity in data:
90
+
91
+ plt.text(
92
+
93
+ job_popularity,
94
+
95
+ resume_popularity,
96
+
97
+ word,
98
+
99
+ ha="left",
100
+
101
+ va="bottom",
102
+
103
+ size=text_size(job_popularity + resume_popularity),
104
+
105
+ )
106
+
107
+
108
+
109
+ plt.xlabel("Popularity on Job Postings")
110
+
111
+ plt.ylabel("Popularity on Resumes")
112
+
113
+ plt.axis([0, 100, 0, 100])
114
+
115
+ plt.xticks([])
116
+
117
+ plt.yticks([])
118
+
119
+ ax.spines["top"].set_visible(False)
120
+
121
+ ax.spines["right"].set_visible(False)
122
+
123
+ plt.show()
124
+
125
+
126
+
127
+ simple_meaningful_word_cloud(data)
128
+
129
+ ```