Yanyg - Software Engineer

Python Matplotlib 绘图

目录

1 Example From axa

# coding=utf8
import matplotlib.pyplot as plt
import numpy as np

with open ('d1.data') as f:
    data1 = [ float(x) for x in f.read().split() ]
    print(data1)

with open ('d2.data') as f:
    data2 = [ float(x) for x in f.read().split() ]
    print(data2)

with open ('d3.data') as f:
    data3 = [ float(x) for x in f.read().split() ]
    print(data3)

#fig, ax = plt.subplots(1, 1)
#my_plotter(ax, data1, data2, {'marker': 'x'})
#plt.figure(figsize=[9,3])
plt.figure()
plt.plot(data1, data2, label="dynamic node")
plt.plot(data1, data3, label="fixed node")
plt.ylabel('Bytes / Item')
plt.xlabel("Item Number")
plt.legend()
plt.title("Memory per item")
plt.savefig("bytes-item.png")
plt.show()

python-matplotlib-byte-item.png