Python绘制简单函数曲线(包括坐标范围限制、刻度指定)
生活随笔
收集整理的這篇文章主要介紹了
Python绘制简单函数曲线(包括坐标范围限制、刻度指定)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
python繪制簡(jiǎn)單函數(shù)曲線,包括坐標(biāo)范圍限制、刻度指定
################### 二維曲線圖 ################## import numpy as np import math import matplotlib.pyplot as pltx = np.arange(-5, 5, 0.1) sigmoid, tanh, relu = [], [], []for t in x:y_1 = 1 / (1 + math.exp(-t))sigmoid.append(y_1)y_1 = (math.exp(t) - math.exp(-t)) / (math.exp(t) + math.exp(-t))tanh.append(y_1)y_1 = max(0, t)relu.append(y_1)plt.plot(x, sigmoid) #plt.ylim(0, 1) plt.show()plt.plot(x, tanh) #plt.ylim(-1, 1) plt.yticks([-1.0, -0.5, 0.0, 0.5, 1.0]) plt.show()plt.plot(x, relu) #plt.ylim(0, 1) plt.show()################### 三維曲線圖 ##################import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3dax = plt.gca(projection='3d') ax.set_xlim([0.7, 1.0]) ax.set_ylim([-0.3, 0.2]) ax.set_zlim([0.8, 1.0]) ax.plot(y_pre[:, 0], y_pre[:, 1], y_pre[:, 2], 'r') ax.plot(ver_y[:, 0], ver_y[:, 1], ver_y[:, 2], 'b') plt.show()?
總結(jié)
以上是生活随笔為你收集整理的Python绘制简单函数曲线(包括坐标范围限制、刻度指定)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 运行launch文件报错Roslaunc
- 下一篇: numpy的常规使用(数组合并、拼接、添