I have files produced by Linux top, sar, vmstat, etc. I've extracted data, for example memory consumption, from those files. Now I want to draw, for example memory consumption curve with Python.
I can write the following code:
from matplotlib import pyplot
x = [1, 2, 3, 4]
y = [3, 4, 5, 6]
pyplot.plot(x, y)
pyplot.xlabel("X - axis")
pyplot.ylabel("Y - axis")
pyplot.title('Hello Matplotlib!')
pyplot.show()
Which can produce the following graph:
But when I use similar code to show memory consumption, matplotlib shows weired graph:
from matplotlib import pyplot
from datetime import datetime
# Memory consumption report time
x = [datetime.strptime(d, '%Y-%m-%d %H:%M:%S') for d in ('2021-02-26 23:22:52',
'2021-02-26 23:27:52',
'2021-02-26 23:43:22',
'2021-02-27 00:03:34')]
# Memory consumption in KiB
y = [169908, 169908, 169908, 170004]
pyplot.plot(x, y)
pyplot.gcf().autofmt_xdate()
pyplot.xlabel("Time")
pyplot.ylabel("Memory consumption")
pyplot.title('Memory monitor')
pyplot.show()
I shows the following graph:
The curve itself looks correct, but the number on Y - axis is weired: why it shows negative number?
How can I get correct memory consumption number (in KiB here) on Y - axis?