If my Temperature data mostly contain 20C and go a bit higher or down then the graph begins from 20C as example and goes to 30C max. I want to go from 0 to 100 regardless what temperature my data has.
I have a second plot that show humidity in % that can go from 0 to 100
I tried set_ylim() but the y axis still begins at 20 and the above is empty with no y numbers on the left.
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
#style.use('dark_background')
style.use('fivethirtyeight')
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
def animate(i):
graph_data = open('example2.txt','r').read()
lines = graph_data.split('\n')
xs = []
ys = []
yz = []
for line in lines:
if len(line) > 1:
x, y, y2= line.split(',')
xs.append(x)
ys.append(float(y)),
yz.append(float(y2))
ax1.grid()
ax1.clear()
ax1.plot(xs, ys)
ax1.plot(xs, yz)
plt.xticks(rotation=45, ha='right')
plt.subplots_adjust(bottom=0.30)
ani = animation.FuncAnimation(fig, animate, interval=1000)
plt.show()
and example2.txt
1,20,30
2,20,30
3,20,30
4,20,30
5,20,32
6,23,35
7,23,33
8,23,32
9,24,29
10,25,26
11,24,28
12,23,30