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()