plot a line in python

To plot a line in Python, you can use the matplotlib library. Here is an example code block that generates a simple line plot:

main.py
import matplotlib.pyplot as plt

# x and y coordinates for the line
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]

# create the plot
plt.plot(x, y)

# add labels and title
plt.xlabel('X Label')
plt.ylabel('Y Label')
plt.title('Line Plot Example')

# show the plot
plt.show()
270 chars
17 lines

This code will generate a line plot with x-coordinates [1, 2, 3, 4, 5] and y-coordinates [2, 4, 6, 8, 10]. You can customize the plot by changing the labels, title, colors, and more.

gistlibby LogSnag