Matplotlib 简单图例
2024-10-18 18:13:43
图例参考:http://matplotlib.org/gallery.html
API参考:http://matplotlib.org/api/pyplot_summary.html
# -*- coding:utf-8 -*-
"""
Simple demo with multiple subplots.
"""
import numpy as np
import matplotlib.pyplot as plt x1 = np.linspace(0.0, 5.0 )
x2 = np.linspace(0.0, 2.0 ) y1 = np.cos(2 * np.pi * x1) * np.exp(-x1)
y2 = np.cos(2 * np.pi * x2) #第一张大图
plt.subplot(2, 1, 1) #
plt.plot(x1, y1, 'ro-')
plt.title('A tale of 2 subplots')
plt.ylabel('Damped oscillation') plt.subplot(2, 1, 2)
plt.plot(x2, y2, '.-')
plt.xlabel('time (s)')
plt.ylabel('Undamped') plt.figure(2) #第二张大图
plt.plot(x1,y1,'o-', label="line1") #添加label说明
plt.plot(x2,y2,'.-', label='line2') #添加label说明
plt.axis([0, 5, -1, 1]) #指定坐标系
plt.legend(loc='best', ncol=1, prop={'size':16}, columnspacing=0.5) #添加备注, loc位置,
plt.title("title")
plt.xlabel("xlabel")
plt.ylabel("ylabel") plt.show()
最新文章
- 实战JS正则表达式
- 走进AngularJs(一)angular基本概念的认识与实战
- 学习vulkan的几个有用的网址
- MIME Sniffing
- Andriod ADB开启Activity、Service以及BroadCast(包括参数的传递)
- Uva10328 dp(递推+高精度)
- OSI安全体系结构
- 基于邻接表的广度优先搜索遍历(bfs)
- JavaScript constructors, prototypes, and the `new` keyword
- BZOJ3190[JLOI2013]赛车
- C# 多线程、结构体
- 安装MySQL后出现发生系统错误2或者系统找不到指定的文件
- 我是怎么知道 PTHREAD_MUTEX_INITIALIZER 是什么鬼东西的 ??
- Response()的对象
- Java使用RabbitMQ之整合Spring(消费者)
- 【tmos】字段update_time如何动态的更新
- 开启hadoop集群
- Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
- android 8.0 intent安装apk失败屏幕闪过
- asp.net core 系列之用户认证(1)-给项目添加 Identity