首页 > 编程知识 正文

pythonmatplotlib怎么画竖线,python怎么用matplotlib画渐近线

时间:2023-05-05 01:53:09 阅读:275965 作者:3255

Python 使用 Matplotlib 做图时,如何画竖直和水平的分割线或者点画线或者直线? 作者:看看
链接:https://www.zhihu.com/question/21929761/answer/164975814

可以使用:

vlines(x, ymin, ymax)

hlines(y, xmin, xmax)

import matplotlib.pyplot as pltimport numpy as np def Laplacian_Prior(x, u, b): return 1.0/(2*b)*np.exp(-abs(x - u)/b) if __name__ == "__main__": x = np.arange(-10, 10, 0.01) y_1 = Laplacian_Prior(x, 0, 1) y_2 = Laplacian_Prior(x, 0, 2) y_3 = Laplacian_Prior(x, 0, 4) y_4 = Laplacian_Prior(x, -5, 4) plt.plot(x, y_1, "r-") plt.plot(x, y_2, "k-") plt.plot(x, y_3, "b-") plt.plot(x, y_4, "g-") plt.vlines(0, 0, 0.5, colors = "c", linestyles = "dashed")

posted on 2017-09-06 12:35 多一点 阅读(...) 评论(...) 编辑 收藏

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。