【发布时间】:2019-05-08 04:13:17
【问题描述】:
我正在尝试使用 Python 上的 matlib 包绘制一些数据。但是,当我尝试绘制一组数据然后设置 y 轴限制时,y 轴上的标签不会显示我想要的全部范围。事实上,它只显示写入数据中的值。
我已尝试更改 y 轴范围。我试过用另一组数据绘制它,但标签似乎没有改变。当我使用具有 80-100 数据的 temp Vec 绘图时,它将显示从 0、100 的整个轴范围。当我尝试绘制相对湿度矢量时,它仅绘制来自可用数据范围的数据大约 0 - 40。
with open('April_26.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter =',')
next(readCSV) #skips the first row which is the headers
#Initialize arrays
timeVec = []
tempVec = []
relHumidityVec = []
#loop through each row
for row in readCSV: #for each row in the CSV file
##Storing specific data
#Note: CSV data is in strings so convert the integers if they are to be
treated as such
time = int(row[0])
temp = int(row[2])
relHum =row[3]
#append to array
timeVec.append(time/1000)
tempVec.append(temp)
relHumidityVec.append(relHum)
#initialize plot
fig, ax = plt.subplots()
#plt.scatter(timeVec, tempVec)
plt.scatter(timeVec, relHumidityVec, s = 4, marker = 'o', c = 'blue' , alpha = 0.4)
plt.scatter(timeVec, tempVec, s = 4, marker = 'o', c = 'red' , alpha = 0.4)
plt.ylim(0, 100)
我希望该图能够绘制我的两个图(温度与时间、相对湿度与时间),同时绘制时间的完整范围和 y 轴从 0 到 100 的完整范围。
【问题讨论】:
标签: python plot label axis scatter