1.matplotlib设置坐标刻度间隔,防止坐标label显示重叠。
import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator# x_values = list(range(0, 11))
# y_values = [x ** 2 for x in x_values]x_values = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
y_values = [x ** 2 for x in range(len(x_values))]plt.plot(x_values, y_values, c='blue')# 创建x轴定位器,间隔2
x_major_locator = MultipleLocator(2)
# 创建y轴定位器,间隔5
y_major_locator = MultipleLocator(5)# 获取轴对象
ax = plt.gca()
# 设置x轴的间隔
ax.xaxis.set_major_locator(x_major_locator)
# 设置y轴的间隔
ax.yaxis.set_major_locator(y_major_locator)# 设置x轴的刻度范围
# plt.xlim('a', 'g')
# 设置y轴的刻度范围
# plt.ylim(0, 40)plt.show()
2.pandas修改列的类型及名称,可用df.columns = df.columns.map(fn)
def convert_dateindex_to_str(date):if len(str(date)) > 5:return str(date)[5:10]else:return datedf.columns = df.columns.map(convert_dateindex_to_str)
3.一直想做那种控件可以拉伸的功能,但是由于对pyqt不太熟悉,一直没找到解决方法,今天用asammdf.exe,看到它有这个功能,于是看了下源码,再结合搜索,终于找到这个功能,实际这个不是控件科拉伸,控件本身就是可拉伸的,但是普通的布局是不支持拉伸的,只能随窗口变化,然后要想手动可以拉的那种,需要一个布局组件,叫QSpliter,具体怎么用,我还得再研究研究。