python使用matplotlib绘图时使刻度线向内
- 刻度向外的程序
import
numpy
as
np
import
matplotlib
.
pyplot
as
plt
num
=
np
.
arange
(
10
)
.
reshape
(
2
,
5
)
##print(num[0])
plt
.
plot
(
num
[
0
]
,
num
[
1
]
)
plt
.
show
(
)
结果:
- 刻度向内的程序
import
numpy
as
np
import
matplotlib
.
pyplot
as
plt
num
=
np
.
arange
(
10
)
.
reshape
(
2
,
5
)
##print(num[0])
plt
.
rcParams
[
'xtick.direction'
]
=
'in'
#将x周的刻度线方向设置向内
plt
.
rcParams
[
'ytick.direction'
]
=
'in'
#将y轴的刻度方向设置向内
plt
.
plot
(
num
[
0
]
,
num
[
1
]
)
plt
.
show
(
)