如何使用Matplotlib绘制折线图

 时间:2026-04-26 23:06:39

1、打开Ubuntu虚拟机,在桌面空白处右键,点击打开终端。

如何使用Matplotlib绘制折线图

2、先安装Matplotlib包,使用pip包管理工具,命令如下:

pip install matplotlib

如何使用Matplotlib绘制折线图

3、使用gedit创建一个python文件,命令如下:

gedit zhexiantu.py

如何使用Matplotlib绘制折线图

4、在gedit.pyz中写代码如下:

import matplotlib.pyplot as plt

x_data = ['2018','2019','2020']

y_data = [10,10.5,10.6]

plt.plot(x_data,y_data)

plt.show()

如何使用Matplotlib绘制折线图

5、在终端启动jupyter notebook,命令如下:

jupyter notebook

如何使用Matplotlib绘制折线图

6、在弹出的浏览器,点击新建 -- Python3

如何使用Matplotlib绘制折线图

7、在输入框输入程序地址,点击运行,折线图效果如下图所示。

%run ~/zhexiantu.py

如何使用Matplotlib绘制折线图

  • 如何用Visual Studio 2010新建立一个c++工程
  • pubwinol设置打印机
  • 新浪滚动新闻JSON解析(PHP版本)
  • 手机QQ如何打开好友互动标识,巨轮,火花,小船
  • JavaScript中Math函数如何使用
  • 热门搜索
    重庆市旅游 南岳衡山旅游攻略 本溪旅游攻略 诸暨旅游 安吉旅游景点 河南旅游年票 文莱旅游 旅游管理系统 摩洛哥旅游 旅游消费券