我不知道如何控制下面代码中从文件中读取数据的条间距。是否有任何方法来调整/调整条之间的空间(不是栏的宽度)?在Input file:
1 4500
2 5000
3 3000
4 4000
5 1000
6 5000#!/usr/bin/python
import numpy as np
import pylab as plot
import matplotlib.pyplot as plt
import numpy, scipy, pylab, random
from matplotlib.ticker import MultipleLocator
import matplotlib as mpl
from matplotlib.ticker import MaxNLocator
with open("file.txt", "r") as f:
x=[]
y=[]
for line in f:
if not line.strip() or line.startswith('@') or line.startswith('#'): continue
row = line.split()
x.append(float(row[0]))
y.append(float(row[1]))
fig = plt.figure(figsize=(3,2))
ax = plt.subplot(111)
plt.ylim(0, 6000)
ax.yaxis.set_major_locator(MaxNLocator(6))