2019-06-04

import numpy as np

import matplotlib.pyplot as plt

mu, sigma = 100, 15

x = mu + sigma * np.random.randn(10000)

# 数据的直方图

n, bins, patches = plt.hist(x, 50, normed=1,edgecolor='b', facecolor='g', alpha=0.2)

plt.xlabel('Smarts')

plt.ylabel('Probability')

#添加标题

plt.title('Histogram of IQ')

#添加文字

plt.text(60, .025, r'$\mu=100,\ \sigma=15$')

plt.axis([40, 160, 0, 0.03])

plt.grid(True)

plt.show

import pylabdef loadData(flieName):    inFile = open(flieName, 'r')    for line in inFile:        trainingSet = line.split('\t')        x.append(eval(trainingSet[0]))        y.append(eval(trainingSet[1]))    return (x, y)x = []y = [](x, y) = loadData('XRD_AFO.txt')pylab.figure(1)pylab.plot(x, y, 'r-')pylab.xlabel('Position(2-Theta)')pylab.ylabel('Intensity')pylab.show()

你可能感兴趣的:(2019-06-04)