import math import matplotlib.pyplot as plt _name_ = '__main__' if _name_ == "__main__": x = [float(i) / 100 for i in range(1, 300)] y = [math.log(i) for i in x] plt.plot(x, y, "r-", linewidth=3, label="log Curve") a = [x[20], x[175]] b = [y[20], y[175]] plt.plot(a, b, "g-", linewidth=2) plt.plot(a, b, "b", markersize=15, alpha=0.75) plt.legend(loc="upper left") plt.grid(True) plt.xlabel("x") plt.ylabel("log(x)") plt.show()
运行结果
import numpy import matplotlib.pyplot as plt __name__ = "__main__" if __name__ == "__main__": u = numpy.random.uniform(0.0, 1.0, 10000) plt.hist(u, 80, facecolor="g", alpha=0.75) plt.grid(True) plt.show() times = 10000 for time in range(times): u += numpy.random.uniform(0.0, 1.0, 10000) print(len(u)) u /= times print(len(u)) plt.hist(u, 80, facecolor="g", alpha=0.75) plt.grid(True) plt.show()
运行结果
标签:__,01,name,show,python,plt,数学,import,main From: https://www.cnblogs.com/xmgcool/p/16929643.html