美文网首页我爱编程
matplotlib画折线图

matplotlib画折线图

作者: 德先森的书 | 来源:发表于2018-04-24 22:55 被阅读0次

1读取数据
import pandas as pd
unrate = pd.read_csv('unrate.csv')
unrate['DATE'] = pd.to_datetime(unrate['DATE']) #转换date数据格式
print(unrate.head(12))
2 画背景
import matplotlib.pyplot as plt
plt.plot()
plt.show()
3 画折线图
first_twelve = unrate[0:12]
plt.plot(first_twelve['DATE'], first_twelve['VALUE'])
plt.show()
4 图表调整

xlabel(): accepts a string value, which gets set as the x-axis label.

ylabel(): accepts a string value, which is set as the y-axis label.

title(): accepts a string value, which is set as the plot title.

plt.plot(first_twelve['DATE'], first_twelve['VALUE'])
plt.xticks(rotation=45)
plt.xlabel('Month')
plt.ylabel('Unemployment Rate')
plt.title('Monthly Unemployment Trends, 1948')
plt.show()

数据和代码参考唐宇迪老师的机器学习课程

相关文章

  • matplotlib折线图

    matplotlib折线图

  • python matplotlib库的使用

    matplotlib画折线图(一)matplotlib配置属性以一个例子开始:假如我们想做一个上证50指数历史最高...

  • matplotlib功能使用_折线图(1)

    matplotlib功能使用之—折线图 一、先做总结 我们利用matplotlib做折线图主要用到以下功能: 1、...

  • matplotlib功能使用_折线图(2)

    matplotlib功能使用之—折线图 一、先做总结 我们利用matplotlib做折线图主要用到以下功能: 1、...

  • matplotlib画折线图

    1读取数据import pandas as pdunrate = pd.read_csv('unrate.csv'...

  • matplotlib画折线图

    matplotlib画折线图 假设一天中每隔两个小时(range(2,26,2))的气温(℃)分别是[15,13,...

  • 2018-04-24

    matplotlib绘图 通常我们可以绘制折线图、饼状图、柱状图,用matplotlib绘制折线图、柱状图情况较多...

  • 2019-06-13 画图

    matplotlib 学习笔记 python使用matplotlib绘制折线图教程 marker画成空心的

  • 数据可视化常用

    1.折线图:matplotlib.pyplot.plot() 2.散点图:matplotlib.pyplot.sc...

  • 1.3 基础 - matplotlib

    对于matplotlib,在机器学习中主要用到matplotlib.pyplot,主要用到plot生成折线图,sc...

网友评论

    本文标题:matplotlib画折线图

    本文链接:https://www.haomeiwen.com/subject/kqyslftx.html