码迷,mamicode.com
首页 > 编程语言 > 详细

python数据可视化,几个最简单的例子

时间:2020-01-29 20:01:52      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:颜色   range   show   最简   size   tle   设置   直方图   cal   

import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd

# 简单的折线图绘制
# x = [1, 2 ,3 ,4, 5]
# y = [1, 4, 9, 16, 25]
# plt.plot(x, y, linewidth = 5)
# plt.title(‘example code‘, fontsize = 40, color = ‘red‘)
# plt.xlabel(‘value‘,fontsize = 20, color = ‘blue‘)
# plt.ylabel(‘vertical‘, fontsize = 20, color = ‘blue‘)
# plt.tick_params(axis = ‘both‘, labelsize = 14)
# plt.show()

# 散点图绘制
# x = [1, 2, 3]
# y = [2, 4, 6]
# plt.scatter(x, y, color = ‘red‘, s = 2000)
# plt.show()

# 绘制加了颜色随某一变量变化的散点图
# x = list(range(1, 1001))
# y = [n**2 for n in x]
# # c=y,设置颜色变量随y值而变化,cmp=...设置颜色值
# plt.scatter(x, y, c = y, cmap = plt.cm.Reds, s = 80)
# plt.show()


# 应用seaborn模块设置主题样式
# sns.set_style(‘whitegrid‘)
# x = list(range(1, 1001))
# y = [n**2 for n in x]
# # c=y,设置颜色变量随y值而变化,cmp=...设置颜色值
# plt.scatter(x, y, c = y, cmap = plt.cm.Reds, s = 80)
# plt.show()

#读取txt格式文件并绘制直方图
df_iris = pd.read_table(df_iris.txt)
# sns.distplot(df_iris[‘petal_length‘],kde = True)
plt.plot(df_iris[petal_length],df_iris[petal_width])
plt.show()

 

python数据可视化,几个最简单的例子

标签:颜色   range   show   最简   size   tle   设置   直方图   cal   

原文地址:https://www.cnblogs.com/iceberg710815/p/12240901.html

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