Exhibit 25.57 provides an example of drawing a line from (1, 3) to (8, 10), using matplotlib.
import matplotlib.pyplot as plt
import numpy as np
# Create arrays for x and y points
xpoints = np.array([1, 8])
ypoints = np.array([3, 10])
# Generate the plot
plt.plot(xpoints, ypoints)
# Add labels and title for clarity
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.title("Line from (1, 3) to (8, 10)")
# Display the plot
plt.show()
The code in Exhibit 25.57 creates two NumPy arrays, xpoints and ypoints, holding the x and y coordinates of the data points. The plt.plot()
function then uses these arrays to generate the line plot. Finally, labels and a title are added for better understanding, and plt.show()
displays the plot.
Use the Search Bar to find content on MarketingMind.
Contact | Privacy Statement | Disclaimer: Opinions and views expressed on www.ashokcharan.com are the author’s personal views, and do not represent the official views of the National University of Singapore (NUS) or the NUS Business School | © Copyright 2013-2025 www.ashokcharan.com. All Rights Reserved.