Python - Datacamp - Introduction to Matplotlib
Python - Datacamp - Introduction to Matplotlib
Datacamp: https://www.datacamp.com/
# 1.py 基本matplotlib.pyplot子模块入门 # Import the matplotlib.pyplot submodule and name it plt
import matplotlib.pyplot as plt # Create a Figure and an Axes with plt.subplots
fig, ax = plt.subplots() # Call the show function
plt.show()
# 2.py 添加数据 import matplotlib.pyplot as plt # 月份
MONTH = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
# 降雨量
rainfall = [44.10, 71.08, 93.36, 184.63, 286.79, 318.60, 238.22, 233.75, 194.35, 68.65, 38.40, 29.32] # 数据
data = {}
data['MONTH'] = MONTH
data['rainfall'] = rainfall # 创建数据以及轴
fig, ax = plt.subplots() # ax: (x, y)
ax.plot(data['MONTH'], data['rainfall']) # 显示
plt.show()
# 3.py 自定义显示 import matplotlib.pyplot as plt # 月份
MONTH = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
# 降雨量
rainfall = [44.10, 71.08, 93.36, 184.63, 286.79, 318.60, 238.22, 233.75, 194.35, 68.65, 38.40, 29.32] # 数据
data = {}
data['MONTH'] = MONTH
data['rainfall'] = rainfall # 创建数据以及轴
fig, ax = plt.subplots() # ax: (x, y)
ax.plot(data['MONTH'], data['rainfall'], color='b', marker='*', linestyle='--') # 显示
plt.show()
# 4.py 自定义标签以及抬头 import matplotlib.pyplot as plt # 月份
MONTH = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
# 降雨量
rainfall = [44.10, 71.08, 93.36, 184.63, 286.79, 318.60, 238.22, 233.75, 194.35, 68.65, 38.40, 29.32] # 数据
data = {}
data['MONTH'] = MONTH
data['rainfall'] = rainfall # 创建数据以及轴
fig, ax = plt.subplots() # ax: (x, y)
ax.plot(data['MONTH'], data['rainfall'], color='b', marker='*', linestyle='--') # 标签
ax.set_xlabel('Months')
ax.set_ylabel('Rainfall in CAN') # 标题
ax.set_title('Weather in CAN') # 显示
plt.show()
# 5.py 多重图表 import matplotlib.pyplot as plt # 月份
MONTH_F = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
MONTH_L = ['Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
# 降雨量
rainfall_canton_F = [44.10, 71.08, 93.36, 184.63, 286.79, 318.60]
rainfall_shanghai_F = [61.79, 59.40, 94.99, 83.19, 92.78, 173.57]
rainfall_canton_L = [238.22, 233.75, 194.35, 68.65, 38.40, 29.32]
rainfall_shanghai_L = [148.84, 193.88, 109.60, 62.44, 54.14, 37.71] # 创建数据以及轴
fig, ax = plt.subplots(2, 2) # ax: (x, y)
ax[0,0].plot(MONTH_F, rainfall_canton_F, color='b', marker='*', linestyle='--')
ax[0,1].plot(MONTH_F, rainfall_shanghai_F, color='r', marker='o', linestyle='--')
ax[1,0].plot(MONTH_L, rainfall_canton_L, color='b', marker='*', linestyle='--')
ax[1,1].plot(MONTH_L, rainfall_shanghai_L, color='r', marker='o', linestyle='--') # 标签
ax[0,0].set_xlabel('Months')
ax[0,0].set_ylabel('Rainfall in Canton')
ax[0,1].set_xlabel('Months')
ax[0,1].set_ylabel('Rainfall in Shanghai') # 标题
ax[0,0].set_title('Weather in Canton')
ax[0,1].set_title('Weather in Shanghai')
# 显示
plt.show()
# 6.py small multiples with shared y axis import matplotlib.pyplot as plt # 月份
MONTH = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
# 降雨量
rainfall = [44.10, 71.08, 93.36, 184.63, 286.79, 318.60, 238.22, 233.75, 194.35, 68.65, 38.40, 29.32]
# 温度
temperature = [10, 14, 20, 22, 19, 25, 30, 31, 32, 29, 15, 16] # 数据
data = {}
data['MONTH'] = MONTH
data['rainfall'] = rainfall
data['temperature'] = temperature # Create a figure and an array of axes: 2 rows, 1 column with shared y axis
fig, axes = plt.subplots(2, 1, sharey=True) axes[0].plot(data['MONTH'], data['rainfall'], color='b')
axes[0].plot(data['MONTH'], data['temperature'], color='b', linestyle='--') axes[1].plot(data['MONTH'], data['rainfall'], color='b')
axes[1].plot(data['MONTH'], data['temperature'], color='b', linestyle='--') plt.show()
Python - Datacamp - Introduction to Matplotlib的更多相关文章
- 学习笔记之Introduction to Data Visualization with Python | DataCamp
Introduction to Data Visualization with Python | DataCamp https://www.datacamp.com/courses/introduct ...
- 在python中使用图形库matplotlib
matplotlib is a python 2D plotting library which produces publication quality figures in a variety o ...
- [置顶] 如何在Windows 7 64位安装Python,并使用Matplotlib绘图
1. 安装Python 我使用的是Windows 7 64 bit,所以我从Python官网下载python-2.7.5.amd64.msi,安装步骤如下: 1) 安装windo ...
- Python数据可视化——使用Matplotlib创建散点图
Python数据可视化——使用Matplotlib创建散点图 2017-12-27 作者:淡水化合物 Matplotlib简述: Matplotlib是一个用于创建出高质量图表的桌面绘图包(主要是2D ...
- 【python笔记】使用matplotlib,pylab进行python绘图
一提到python绘图,matplotlib是不得不提的python最著名的绘图库,它里面包含了类似matlab的一整套绘图的API.因此,作为想要学习python绘图的童鞋们就得在自己的python ...
- Python的可视化包 – Matplotlib 2D图表(点图和线图,.柱状或饼状类型的图),3D图表(曲面图,散点图和柱状图)
Python的可视化包 – Matplotlib Matplotlib是Python中最常用的可视化工具之一,可以非常方便地创建海量类型地2D图表和一些基本的3D图表.Matplotlib最早是为了可 ...
- python安装matplotlib:python -m pip install matplotlib报错
matplotlib是python中强大的画图模块. 首先确保已经安装python,然后用pip来安装matplotlib模块. 进入到cmd窗口下,建议执行python -m pip install ...
- Python使用pip安装matplotlib模块
matplotlib是python中强大的画图模块. 首先确保已经安装python,然后用pip来安装matplotlib模块. 进入到cmd窗口下,建议执行python -m pip install ...
- 用Python的Pandas和Matplotlib绘制股票KDJ指标线
我最近出了一本书,<基于股票大数据分析的Python入门实战 视频教学版>,京东链接:https://item.jd.com/69241653952.html,在其中给出了MACD,KDJ ...
随机推荐
- servlet理解
可得到一个结论:该JSP页面中的每个字符都由test1_jsp.java文件的输出流生成. 根据上面的JSP页面工作原理图,可以得到如下四个结论: — JSP文件必须在JSP服务器内运行. — JSP ...
- plsql developer ini
plsql developer ini [Colors] GradientEnabled=True VerticalGradient=True DefaultGradient=True Gradien ...
- RubyMine生成reader/writer方法
RubyMine生成reader/writer方法 在非类的ruby文件中,Alt+Insert会出现新建文件的选项: 在ruby文件的类中,Alt+Insert会出现get/set方法生成提示和重构 ...
- 【函数式】Monads模式初探——Endofunctor
自函子 自函子(Endofunctor)是一个将范畴映射到自身的函子(A functor that maps a category to itself). 函子是将一个范畴转换到另一个范畴.所以自函子 ...
- 关于Mysql Enterprise Audit plugin的使用
正如之前看到的一篇文章,假设想要知道是谁登陆了你的数据库server,干了什么东西,那么你须要使用Mysql Enterprise Audit plugin. 以下介绍一下Mysql Enterpri ...
- [Sencha ExtJS & Touch] 在Sencha(Extjs/Touch)应用程序中使用plugins(插件)和mixins(混入)
原文链接:http://blog.csdn.net/lovelyelfpop/article/details/50853591 英文原文:Using Plugins and Mixins in You ...
- jquery非文本框复制
function selectText(x) { if (document.selection) { var range = document.body.createTextRange();//ie ...
- Github 协同开发
ithub开发流程 Github的流程.也就是: 开发者各自fork项目的repo到自己Github账户下 每次开发同步到项目的repo然后再进行开发 push自己的开发分支到自己Github账户下面 ...
- poj--1664--放苹果(递归好体)
放苹果 Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64u Submit Status De ...
- raspberry-常用命令
安全关闭raspberry:sudo shutdown -h now 一次升级系统中的所有内容:sudo apt-get update 升级单个软件包:sudo apt-get install *** ...