Skip to content

Latest commit

 

History

History
74 lines (55 loc) · 2.03 KB

numPy notes.md

File metadata and controls

74 lines (55 loc) · 2.03 KB

Usage Provide instructions on how to use your project or code. Include code examples or usage scenarios if necessary.

python Copy code import library_name

Example code or usage

NumPy Functions np.zeros() The np.zeros() function creates an array filled with zeros. It takes the shape of the desired array as an argument.

python Copy code import numpy as np

Create a 2x3 array filled with zeros

zeros_array = np.zeros((2, 3)) np.eye() The np.eye() function creates an identity matrix (a square matrix with ones on the main diagonal and zeros elsewhere). It takes the matrix's size as an argument.

python Copy code import numpy as np

Create a 3x3 identity matrix

identity_matrix = np.eye(3) np.ones() The np.ones() function creates an array filled with ones. It takes the shape of the desired array as an argument.

python Copy code import numpy as np

Create a 4x2 array filled with ones

ones_array = np.ones((4, 2)) np.linspace() The np.linspace() function generates evenly spaced numbers over a specified range. It takes the start, stop, and number of points as arguments.

python Copy code import numpy as np

Generate 10 equally spaced values between 0 and 1

evenly_spaced_values = np.linspace(0, 1, 10) Matplotlib Functions plt.imshow() The plt.imshow() function in Matplotlib is used for displaying images. It can show both 2D arrays (grayscale) and 3D arrays (RGB images).

python Copy code import matplotlib.pyplot as plt

Display an image

plt.imshow(image_array, cmap='gray') # For grayscale image plt.plot() The plt.plot() function in Matplotlib is used for creating line plots and scatter plots.

python Copy code import matplotlib.pyplot as plt

Create a line plot

x = [1, 2, 3, 4, 5] y = [10, 12, 8, 15, 9] plt.plot(x, y, label='Line Plot') plt.legend() plt.show() Feel free to replace library_name, image_array, and the code examples with relevant information and code snippets specific to your project. Additionally, consider adding more sections to your README to provide comprehensive documentation for your project's users and contributors.