#!/usr/bin/env python
import sys
import numpy as np
import matplotlib.pyplot as plt
import re
from math import log, sqrt, pi
def read_file(file):
temp = []
file.readline()
for line in file:
temp.append([line.split(',')[0],log(float(line.split(',')[6]))])
data = np.array(temp)
return data
def main():
data1 = []
data2 = []
file1 = open('./Couette_debug.hist')
file2 = open('./Couette_origin.hist')
data1 = read_file(file1)
data2 = read_file(file2)
plot1 = plt.figure()
plt.figure(figsize=(6,4.8))
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.ylabel(r" $\textbf{Residual}[\rho E]$")
plt.xlabel(r"$\textbf{t}$")
plt.plot(data1[:,0],data1[:,1], 'r-', label = 'preconditioning',linewidth=1.8)
plt.plot(data2[:,0],data2[:,1], 'b--', label = 'origin',linewidth=1.8)
plt.legend(loc='best',frameon=True)
plt.savefig('couette_hist.png')
if __name__ == '__main__':
main()
一个Matplotlib绘图例子
最新推荐文章于 2024-01-21 10:30:00 发布