码迷,mamicode.com
首页 > 其他好文 > 详细

matplotlib安装及使用

时间:2018-05-22 12:38:28      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:plot   otl   文件   标记   标题   绘制   class   决定   设置   

  1. matplotlib的安装                                                                                                                                                                                                                                                                                                                                     我使用的是pycharm开发,直接在.py文件里导入import matplotlib,如果报错则证明没有安装,点击修成错误,pycharm会自动帮我们安装
  2. 绘制简单的折线图  
import matplotlib.pyplot as plt


squares = [1, 4, 9, 16, 34]
plt.plot(squares)
plt.show()

  3. 校正图形

import matplotlib.pyplot as plt

input_values = [1, 2, 3, 4, 5]
squares = [1, 4, 9, 16, 25]
plt.plot(input_values, squares, linewidth=5)  # linewidth决定了线条的粗细

# 设置图表标题,并给坐标轴加上标签
plt.title(‘Square Numbers‘, fontsize=24)
plt.xlabel("Value", fontsize=14)
plt.ylabel(‘Square of value‘, fontsize=14)
plt.show()

# 设置刻度标记的大小
plt.tick_params(axis=‘both‘, labelsize=14)

  

matplotlib安装及使用

标签:plot   otl   文件   标记   标题   绘制   class   决定   设置   

原文地址:https://www.cnblogs.com/endian11/p/9070940.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!