-
2
查看全部 -
1
查看全部 -
3
查看全部 -
2
查看全部 -
1
查看全部 -
目錄
查看全部 -
data=[[1,2,4],[2,6,8]]
data.shape#data的數據維度,多少行多少列
data.dtype#data的數據類型
data.size#data有多少元素
查看全部 -
2
查看全部 -
1
查看全部 -
#20180423
# -*- coding: cp936 -*-
import numpy as np
import matplotlib.pyplot as plt
def run():
? ? #-pi和pi之間取256個點,并包含最后一個點
? ? x = np.linspace(-np.pi, np.pi, 256, endpoint=True)
? ? #e為cosx, f為sin(x)
? ? c, d = np.cos(x), np.sin(x)?
? ? plt.figure(1) #指定圖1
? ? plt.plot(x, c, color='blue', linewidth=1.0, linestyle='-', label="Cos", alpha=0.1)
? ? #*表示線型為由*點構成
? ? plt.plot(x, d, "r*", label='Sin')
? ? plt.title("Cos&Sin")
? ? ax=plt.gca()
? ? #spines表示四周的線
? ? ax.spines["right"].set_color("none")
? ? ax.spines["top"].set_color("none")
? ? #坐標軸起始設置
? ? ax.spines["left"].set_position(("data", 0))
? ? ax.spines["bottom"].set_position(("data", 0))#此處為兩個括弧
? ? #20180425
? ? ax.xaxis.set_ticks_position('bottom')? ? ? ? #設置x軸的標注位于bottom軸
? ? ax.yaxis.set_ticks_position('left')?
? ? plt.yticks(np.linspace(-np.pi,np.pi,5,endpoint=True))
? ? plt.yticks(np.linspace(-1,1,5,endpoint=True))
? ? for label in ax.get_xticklabels()+ax.get_yticklabels():
? ? ? ? #改變label的大小
? ? ? ? label.set_fontsize(16)??
? ? ? ? #設置label的小方塊及其背景
? ? ? ? label.set_bbox(dict(facecolor='white',edgecolor))
? ? #標注sin和cos的圖例
? ? plt.legend(loc='upper left')
? ? #顯示網格線
? ? plt.grid()
? ? #當x絕對值小于0.5,為真記為1,此范圍內從1開始到曲線cosx填充,其余為0開始到曲線cosx填充,c>0.5確定橫軸范圍x,保證c=cosx>0.5
? ? plt.fill_between(x,np.abs(x)<0.5,c,c>0.5,color='green',alpha=0.1)
? ? plt.show()
run()
查看全部 -
read_excel()讀取Excel文件,保存用to_csv()或者to_excel()
查看全部 -
pandas讀取csv文件,用read_csv()語句
查看全部 -
用contact對數組進行拼接,比如前三行和后三行拼接
查看全部 -
apply()可以直接應用函數,或者應用自定義函數
查看全部 -
shift()數字移動,diff()減法,value_counts()某個值出現的次數。
查看全部
舉報