回答編集履歴

2

change result

2022/12/19 20:34

投稿

ps_aux_grep
ps_aux_grep

スコア1579

test CHANGED
@@ -15,8 +15,8 @@
15
15
  ax.set_xlim(5, 30)
16
16
  ax.set_ylim(1e-8, 1e-5)
17
17
 
18
- ax.set_xticks([5, 10, 20, 30])
18
+ ax.set_xticks([5, 10, 20, 30], minor = True)
19
- ax.set_xticklabels([5, 10, 20, 30])
19
+ ax.set_xticklabels([5, 10, 20, 30], minor = True)
20
20
 
21
21
  ax.set_title('fig.2')
22
22
  ax.set_xlabel("x")
@@ -24,4 +24,4 @@
24
24
  plt.show()
25
25
  ````
26
26
 
27
- ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-12-18/59e983e7-f036-4f46-8e1f-74fcdd5530bc.png)
27
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-12-20/9dbc3528-017f-432b-a473-e563bd2cae09.png)

1

fix answer

2022/12/18 14:41

投稿

ps_aux_grep
ps_aux_grep

スコア1579

test CHANGED
@@ -1,5 +1,27 @@
1
1
  [matplotlib.axes.Axes.set_xticks ](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_xticks.html)
2
2
 
3
- 無理やり`ax.set_xticks([5, 10, 20, 30], [5, 10, 20, 30])`とラベルを書いやると反映れます
3
+ 次のようにラベルを併記しくだ
4
4
 
5
+ ```Python
6
+ x = np.linspace(6, 20, 100)
7
+ y = 1e-7 * (x - 1e-8) + np.random.randn(100) * 1e-7
8
+
9
+ fig = plt.figure()
10
+ ax = fig.add_subplot(1, 1, 1)
11
+ ax.scatter(x, y)
12
+ ax.set_xscale("log")
13
+ ax.set_yscale("log")
14
+
15
+ ax.set_xlim(5, 30)
16
+ ax.set_ylim(1e-8, 1e-5)
17
+
18
+ ax.set_xticks([5, 10, 20, 30])
19
+ ax.set_xticklabels([5, 10, 20, 30])
20
+
21
+ ax.set_title('fig.2')
22
+ ax.set_xlabel("x")
23
+ ax.set_ylabel("y")
24
+ plt.show()
25
+ ````
26
+
5
- ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-12-17/e3d5de9b-b9a3-46b9-9a71-19de5c050770.png)
27
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-12-18/59e983e7-f036-4f46-8e1f-74fcdd5530bc.png)