matplotlib

(1)坐标轴缩放

import matplotlib.pyplot as plt

x = [10**i for i in range(10)]

y = [i for i in range(10)]

plt.plot(x,y,c="b")

plt.scatter(x,y) #点图

 

设置X轴的缩放度

plt. xscale("log")

 

(2)X轴刻度的设置

from matplotlib.pyplot import MultipleLocator

import matplotlib.pyplot as plt

建立画布

fig,ax = plt.subplots()

x = y =list(range(10))

 

ax.plot(x,y,label = r'$y = x$')

ax.legend()

 

设置刻度长度

吧X轴刻度的长度设置为n,并存在变量里

x_major_locator = MulitipleLocator(1)

 

获取当前子图

ax = plt.gca()

后续操作是在ax这个图上操作

 

将X轴的主刻度设置为1的倍数

ax.xaxis.set_major_locator(x_major_locator)

 

 

设置X,Y轴刻度比例尺

ax.set_aspect(1)

 

 

设置X,Y轴的刻度

plt.xticks()参数说明

ticks:x轴刻度位置的参数

label:参数对应的值

 

posted @ 2022-05-12 16:33  啊诚  阅读(36)  评论(0编辑  收藏  举报