import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
fig, ax = plt.subplots()
# 设置主刻度间隔为 1
major_locator = ticker.MultipleLocator(1)
ax.xaxis.set_major_locator(major_locator)
# 设置副刻度间隔为 0.5
minor_locator = ticker.MultipleLocator(0.5)
ax.xaxis.set_minor_locator(minor_locator)
# 设置刻度标签格式
ax.xaxis.set_major_formatter(ticker.FormatStrFormatter(‘%.0f’))
ax.xaxis.set_minor_formatter(ticker.FormatStrFormatter(‘%.1f’))
# 绘制数据
x = [1, 2, 3, 4, 5, 6]
y = [1, 4, 9, 16, 25, 36]
ax.plot(x, y)
plt.show()

輸出結果:

推薦hahow線上學習python: https://igrape.net/30afN

![Python TQC考題610 平均溫度,不要自找麻煩用2D list做,可練習2D轉1D: 一維串列.extend(二維串列[index]) Python TQC考題610 平均溫度,不要自找麻煩用2D list做,可練習2D轉1D: 一維串列.extend(二維串列[index])](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2022/05/20220515192908_35.png?quality=90&zoom=2&ssl=1&resize=350%2C233)





![Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index) Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index)](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2025/04/20250420212553_0_6fb2c3.png?quality=90&zoom=2&ssl=1&resize=350%2C233)


近期留言