回答編集履歴

2

修正

2020/08/12 06:32

投稿

can110
can110

スコア38266

test CHANGED
@@ -1,6 +1,6 @@
1
1
  公式の[Keypress Demo](https://matplotlib.org/3.1.0/gallery/event_handling/keypress_demo.html)が参考になります。
2
2
 
3
- 以下は入力されたキー値をxラベルとして表示する例です。
3
+ 以下は入力されたキー値をxラベルとグラフ内のtextとして表示する例です。
4
4
 
5
5
  ```Python
6
6
 

1

コード修正

2020/08/12 06:32

投稿

can110
can110

スコア38266

test CHANGED
@@ -16,6 +16,8 @@
16
16
 
17
17
  ax.set_xlabel(event.key)
18
18
 
19
+ txt.set_text(event.key)
20
+
19
21
  plt.draw()
20
22
 
21
23
 
@@ -30,6 +32,8 @@
30
32
 
31
33
  ax.set_title('Press a key')
32
34
 
35
+ txt = ax.text(1,1,'', fontsize=24)
36
+
33
37
  plt.show()
34
38
 
35
39
  ```