Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Broadcasting with NumPy Arrays Plotting a two-dimensional function Example

# welcome to softhunt.net
import numpy as np
import matplotlib.pyplot as plt

# Computes x and y coordinates for
# points on sine and cosine curves
x = np.arange(0, 3 * np.pi, 0.1)
y_sin = np.sin(x)
y_cos = np.cos(x)

# Plot the points using matplotlib
plt.plot(x, y_sin)
plt.plot(x, y_cos)
plt.xlabel('x axis label')
plt.ylabel('y axis label')
plt.title('Sine and Cosine')
plt.legend(['Sine', 'Cosine'])

plt.show()
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Broadcasting #NumPy #Arrays #Plotting #function #Example
ADD COMMENT
Topic
Name
3+2 =