【Matplotlib】概要总览第一讲
2016-06-24 18:27
627 查看
之前一直使用 matplotlib, 但都是随用随查,现在特开此系列帖子已记录其学习过程。
文档链接:
plot tutorial
plot() command
matplotlib 中提供了一系列的参数,比如 图形大小(figure size),图形质量(dpi), 线宽(linewidth), 颜色和样式(color and style), axes, axis and grid properties, text and font properties 等等。
先举个简单的例子(使用默认设置):
实例化设置初始设置:
文档链接:
Customizing matplotlib
增加相关的设置后代码如下:
具体设置下一节再说吧。
Matplotlib可能是Python 扩展包中仅有的最流行的 2D 绘图库。她不仅提供了快速的方式可视化
Python中的数据,而且提供流行的图形格式的选择。
pyplot是非常接近
Matlab的一个函数库,承担了大部分的绘图任务。我们可以通过以下命令引入
pyplot.
from matplotlib import pyplot as plt
文档链接:
plot tutorial
plot() command
matplotlib 中提供了一系列的参数,比如 图形大小(figure size),图形质量(dpi), 线宽(linewidth), 颜色和样式(color and style), axes, axis and grid properties, text and font properties 等等。
先举个简单的例子(使用默认设置):
import numpy as np import matplotlib.pyplot as plt X = np.linspace(-np.pi, np.pi, 256, endpoint=True) C, S = np.cos(X), np.sin(X) plt.plot(X, C) plt.plot(X, S) plt.show()
实例化设置初始设置:
文档链接:
Customizing matplotlib
增加相关的设置后代码如下:
import numpy as np import matplotlib.pyplot as plt # Create a figure of size 8x6 inches, 80 dots per inch plt.figure(figsize=(8, 6), dpi=80) # Create a new subplot from a grid of 1x1 plt.subplot(1, 1, 1) X = np.linspace(-np.pi, np.pi, 256, endpoint=True) C, S = np.cos(X), np.sin(X) # Plot cosine with a blue continuous line of width 1 (pixels) plt.plot(X, C, color="blue", linewidth=1.0, linestyle="-") # Plot sine with a green continuous line of width 1 (pixels) plt.plot(X, S, color="green", linewidth=1.0, linestyle="-") # Set x limits plt.xlim(-4.0, 4.0) # Set x ticks plt.xticks(np.linspace(-4, 4, 9, endpoint=True)) # Set y limits plt.ylim(-1.0, 1.0) # Set y ticks plt.yticks(np.linspace(-1, 1, 5, endpoint=True)) # Save figure using 72 dots per inch # plt.savefig("exercice_2.png", dpi=72) # Show result on screen plt.show()
具体设置下一节再说吧。
相关文章推荐
- vsftpd.conf
- PHP中 echo, print_r与var_dump的区别分析
- phpcms(4) V9 栏目管理
- phpcms(3) V9 常用函数 及 代码整理(转)
- phpcms v9 后台添加修改页面空白页问题解决方法
- php 进行子网换算(二进制,解决32位/64位系统超出最大int)
- PHPCMS(2)PHPCMS V9 环境搭建(转)
- php实现时间戳转换在32位系统下超过2038年的自定义处理函
- PHP100张恩民谈:IT人员短时间内获取三年工作经验
- phpcms(1)phpcms V9 MVC模式 与 URL访问解析(转)
- U-boot中TFTP 解释
- 开源内容管理系统Joomla正式发布3.5版本 基于PHP 7
- phpstorm ftp 使用
- YII框架安装过程-数据库访问
- FTP 协议
- 为什么做Web开发要选择PHP
- PHP5中PDO的简单使用
- PHP学习资源
- php去掉二维数组中某key的值
- PHP:stream_context_create函数模拟POST/GET请求