01 2023 档案
摘要:import matplotlib.pyplot as plt import numpy as np x = np.arange(0,10,0.1) y1 = 0.05*x**2 y2 = -1*y1 fig,ax1 = plt.subplots() ax2 = ax1.twinx() ax1.pl
阅读全文
摘要:import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec fig = plt.figure() x = [1,2,3,4,5,6,7] y = [1,3,4,5,6,8,6] left,bottom,width,he
阅读全文
摘要:import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec #method 1 plt.figure() ax1 = plt.subplot2grid((3,3),(0,0),colspan=3,rowspan=1)
阅读全文
摘要:import matplotlib.pyplot as plt plt.figure() plt.subplot(2,1,1) plt.plot([0,1],[0,1]) plt.subplot(2,3,4) plt.plot([0,1],[0,2]) plt.subplot(2,3,5) plt.
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = Axes3D(fig) X = np.arange(-4,4,0.25
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np #image data a = np.array([0.31366,0.36534,0.42373, 0.36534,0.43959,0.53444, 0.42333,0.52555,0.65566
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np def f(x,y): #the height function return (1 - x/2 + x**5 + y**3)*np.exp(-x**2-y**2) n=256 x=np.linsp
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np n=12 X=np.arange(n) Y1=(1-X/float(n))*np.random.uniform(0.5,1.0,n) Y2=(1-X/float(n))*np.random.unif
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np n=1024 X = np.random.normal(0,1,n) Y = np.random.normal(0,1,n) T = np.arctan2(Y,X)#for color value
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np x = np.linspace(-3,3,50) y = 0.1*x plt.figure() #范围 plt.xlim((-4,4)) plt.ylim((-5,5)) plt.xlabel('X
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np x = np.linspace(-3,3,50) y = 2*x+1 plt.figure() #范围 plt.xlim((-3,4)) plt.ylim((-3,6)) #轴含义(标签) plt.
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np x = np.linspace(-1,1,50) y1 = 2*x+1 y2 = x**2 plt.figure() #范围 plt.xlim((-1,2)) plt.ylim((-2,3)) #轴
阅读全文
摘要:```pythonimport matplotlib.pyplot as pltimport numpy as np x = np.linspace(-1,1,50)y1 = 2*x+1y2 = x**2 plt.figure()plt.plot(x,y2)plt.plot(x,y1,color='
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np x = np.linspace(-1,1,50) y1 = 2*x+1 y2 = x**2 plt.figure() plt.plot(x,y2) plt.plot(x,y1,color='red'
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np x = np.linspace(-1,1,50) y1 = 2*x+1 y2 = x**2 plt.figure(num=1,figsize=(10,10)) plt.plot(x,y1) plt.
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np x = np.linspace(-1,1,50) #y = 2*x+1 y = x**2 plt.plot(x,y) plt.show()
阅读全文
摘要:import numpy as np #行合并 a = np.arange(6).reshape(2,3) b = np.random.randint(10,20,size=(4,3)) print(a) print(b) print('*******************************
阅读全文
摘要:import numpy as np arr = np.arange(5) print(arr) print(arr.shape) #method1 print(arr[np.newaxis,:]) print(arr[np.newaxis,:].shape) print(arr[:,np.newa
阅读全文
摘要:import numpy as np arr = np.arange(12).reshape(3,4) print(arr) print(np.sum(arr)) print(np.prod(arr)) print(np.cumsum(arr)) print(np.cumprod(arr)) pri
阅读全文
摘要:import numpy as np np.random.seed(666) print(np.random.rand(5)) print(np.random.rand(3,4)) print(np.random.rand(2,3,4)) print('***********************
阅读全文
摘要:import numpy as np #基础索引 x1 = np.arange(10) x2 = np.arange(20).reshape(4,5) print(x1) print(' ') print(x1[0],x1[9],x1[-1]) print(' ') print(x1[2:4]) p
阅读全文
摘要:import numpy as np x1 = np.array([1,2,3,4,5,6,7,8]) x2 = np.array( [ [1,2,3,4], [5,6,7,8] ]) #返回元组,表维度 print(x1.shape) print(x2.shape) #返回数字,表维度 print
阅读全文
摘要:import numpy as np from timeit import timeit def python_sum(n): a=[i**2 for i in range(n)] b=[i**3 for i in range(n)] c=[] for i in range(n): c.append
阅读全文