python plt.plot
时间: 2023-10-26 18:48:28 浏览: 74
plt.plot() is a function in the Python matplotlib library used to create a line plot. It takes in two or more arrays of data and creates a line plot of the values. The syntax for plt.plot() is as follows:
plt.plot(x, y, color, linestyle, linewidth, marker, markersize)
where:
- x: array-like or scalar. The x-coordinates of the data points.
- y: array-like or scalar. The y-coordinates of the data points.
- color: string. The color of the line.
- linestyle: string. The style of the line.
- linewidth: float. The width of the line.
- marker: string. The shape of the marker at each data point.
- markersize: float. The size of the marker.
Here's an example:
import numpy as np
import matplotlib.pyplot as plt
# Create some data
x = np.linspace(0, 10, 100)
y = np.sin(x)
# Plot the data
plt.plot(x, y, color='blue', linestyle='-', linewidth=2, marker='o', markersize=5)
# Set the title and axis labels
plt.title('Sinusoidal Plot')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
# Show the plot
plt.show()
阅读全文