python数据可视化,几个最简单的例子
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()
相关推荐
comtop0 2020-10-31
嵌入式企鹅圈 2020-10-27
comtop0 2020-09-18
alili 2020-09-08
xirongxudlut 2020-09-02
wndong 2020-08-21
Leonwey 2020-08-02
Tonybo 2020-08-02
YtSports 2020-07-28
syThinkCool 2020-07-16
flyfor0 2020-07-16
SanBa 2020-07-08
HongAndYi 2020-07-04
王国平 2020-06-20
Eric0Lv 2020-06-14
june0 2020-06-11
仁鱼 2020-06-05
天涯莺歌 2020-06-04
Leonwey 2020-06-01