zsh2270365028的个人博客分享 http://blog.sciencenet.cn/u/zsh2270365028

博文

[转载]python-hlines and vlines(水平线和竖直线)

已有 6446 次阅读 2019-10-12 16:20 |个人分类:Python|系统分类:科研笔记|文章来源:转载

refer to:

https://matplotlib.org/gallery/lines_bars_and_markers/vline_hline_demo.html#sphx-glr-gallery-lines-bars-and-markers-vline-hline-demo-py

This example showcases the functions hlines and vlines.

../../_images/sphx_glr_vline_hline_demo_001.png

import matplotlib.pyplot as pltimport numpy as np
t = np.arange(0.0, 5.0, 0.1)
s = np.exp(-t) + np.sin(2 * np.pi * t) + 1
nse = np.random.normal(0.0, 0.3, t.shape) * s
fig, (vax, hax) = plt.subplots(1, 2, figsize=(12, 6))
vax.plot(t, s + nse, '^')
vax.vlines(t, [0], s)# By using ``transform=vax.get_xaxis_transform()`` the y coordinates are scaled# such that 0 maps to the bottom of the axes and 1 to the top.
vax.vlines([1, 2], 0, 1, transform=vax.get_xaxis_transform(), colors='r')
vax.set_xlabel('time (s)')
vax.set_title('Vertical lines demo')
hax.plot(s + nse, t, '^')
hax.hlines(t, [0], s, lw=2)
hax.set_xlabel('time (s)')
hax.set_title('Horizontal lines demo')
plt.show()


https://blog.sciencenet.cn/blog-587102-1201640.html

上一篇:[转载]matplotlib命令与格式:标题(title),标注(annotate),文字说明(text)
下一篇:[转载]python查询字符串中指定字符的索引
收藏 IP: 119.78.226.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-24 17:02

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部