Python笔记 #09# Basic plots with matplotlib
源:DataCamp

气泡的大小表示人口的多少,横坐标表示人均GDP(美元),纵坐标表示预期寿命。-- 作者:Hans Rosling
Python 中有许许多多用于可视化的包,而 matplotlib 是它们的源头。
我们需要用到的是它的子包 pyplot ,通常它被简写成 plt 导入
1、Line plot

# Print the last item from year and pop
print(year[-1])
print(pop[-1]) # Import matplotlib.pyplot as plt
import matplotlib.pyplot as plt # Make a line plot: year on the x-axis, pop on the y-axis
plt.plot(year, pop) # Display the plot with plt.show()
plt.show()
\

# Print the last item of gdp_cap and life_exp
print(gdp_cap[-1])
print(life_exp[-1]) # Make a line plot, gdp_cap on the x-axis, life_exp on the y-axis
plt.plot(gdp_cap, life_exp) # Display the plot
plt.show()
2、Scatter Plot
When you have a time scale along the horizontal axis, the line plot is your friend. But in many other cases, when you're trying to assess if there's a correlation between two variables, for example, the scatter plot is the better choice. Below is an example of how to build a scatter plot.

# Change the line plot below to a scatter plot
plt.scatter(gdp_cap, life_exp) # Put the x-axis on a logarithmic scale
plt.xscale('log') # Show plot
plt.show()
\

# Import package
import matplotlib.pyplot as plt # Build Scatter plot
plt.scatter(pop, life_exp) # Show plot
plt.show()
Python笔记 #09# Basic plots with matplotlib的更多相关文章
- Intermediate Python for Data Science learning 1 - Basic plots with matplotlib
Basic plots with matplotlib from:https://campus.datacamp.com/courses/intermediate-python-for-data-sc ...
- python笔记09
今日内容 三元运算 函数 内容详细 三元运算(三目运算) v = 前面 if 条件 else 后面 if 条件: v = '前面' else: v = '后面' # 让用户输入值,如果值是整数,则转换 ...
- 机器学习实战(Machine Learning in Action)学习笔记————09.利用PCA简化数据
机器学习实战(Machine Learning in Action)学习笔记————09.利用PCA简化数据 关键字:PCA.主成分分析.降维作者:米仓山下时间:2018-11-15机器学习实战(Ma ...
- python笔记之常用模块用法分析
python笔记之常用模块用法分析 内置模块(不用import就可以直接使用) 常用内置函数 help(obj) 在线帮助, obj可是任何类型 callable(obj) 查看一个obj是不是可以像 ...
- python笔记-1(import导入、time/datetime/random/os/sys模块)
python笔记-6(import导入.time/datetime/random/os/sys模块) 一.了解模块导入的基本知识 此部分此处不展开细说import导入,仅写几个点目前的认知即可.其 ...
- s21day25 python笔记
s21day25 python笔记 正则表达式 1.定义 定义:正则表达式是一种规则匹配字符串的规则 re模块本身只是用来操作正则表达式的,和正则本身没关系 为什么要有正则表达式? 匹配字符串 一个人 ...
- Python笔记之不可不练
如果您已经有了一定的Python编程基础,那么本文就是为您的编程能力锦上添花,如果您刚刚开始对Python有一点点兴趣,不怕,Python的重点基础知识已经总结在博文<Python笔记之不可不知 ...
- boost.python笔记
boost.python笔记 标签: boost.python,python, C++ 简介 Boost.python是什么? 它是boost库的一部分,随boost一起安装,用来实现C++和Pyth ...
- 20.Python笔记之SqlAlchemy使用
Date:2016-03-27 Title:20.Python笔记之SqlAlchemy使用 Tags:python Category:Python 作者:刘耀 博客:www.liuyao.me 一. ...
随机推荐
- Chosen
前言: 想要达到下拉框有多选的情况. 过程: 1.因为本次工作项目使用的是surperUI,而它则是基于bootstrap框架搭建而成的.于是自然而然的就想到了使用bootstrap中的select插 ...
- webstorm编译less和scss
Webstorm 配置less编译的Arguments参数: $FileName$ $FileParentDir$\ccy\ccy1\ccy2\$FileNameWithoutExtension$.c ...
- select 相关 获取当前项以及option js选定
$("#product option[value='170']").prop("selected","true")//要确定是selecte ...
- 为非ajax请求绑定回调函数的方法
我们都知道jQuery为ajax请求封装了success和error两个回调方法,其实jQuery也实现了为非ajax请求的普通方法也设计了绑定回调函数的方法. 当一个方法需要等待另一个耗时很长的方法 ...
- 使用MAT分析Java内存
Overview MAT(Memory Analyzer Tool) 是一个JAVA Heaper分析器,可以用来分析内存泄露和减少内存消耗.分析Process showmap中的/dev/ashme ...
- 图论之最短路径(2)——Bellman-Ford算法
继续最短路径!说说Bellman—Ford算法 思路:假设起点为s,图中有n个顶点和m个边,那么它到任一点(比如i)的最短路径 最多可以有n-1条(没有回路就是n-1条):因为最短路径中不可能包含回路 ...
- linux 程序启动与停止管理脚本
公司接了一个第三方的系统,基于linux写的几个程序,一共有9个部件,第三方没有给脚本,每次启动或停止都得一个一个手工去停止或修改.......,这里稍微鄙视下. 没办法,求人还不如自己动手写, 需求 ...
- 微信小程序 --- 用户登录
整体逻辑:点击用户中心,如果如果整个页面没有
- VC编译选项 多线程(/MT)
VC编译选项 多线程(/MT)多线程调试(/MTd)多线程 DLL (/MD)多线程调试 DLL (/MDd)C 运行时库 库文件Single threa ...
- Redis讲解
buffer 缓冲 用于写 cache 缓存 用于读 redis 支持持久化 安装redis yum -y install redis 配置文件/etc/redis.conf 是否在后台运行 ...