Write a program to plot two lines with different colours.please urgent
Answers
Answered by
1
Answer:
Python Code:
import matplotlib.pyplot as plt
# line 1 points
x1 = [10,20,30]
y1 = [20,40,10]
# line 2 points
x2 = [10,20,30]
y2 = [40,10,30]
# Set the x axis label of the current axis.
plt.xlabel('x - axis')
# Set the y axis label of the current axis.
plt.ylabel('y - axis')
# Plot lines and/or markers to the Axes.
plt.plot(x1,y1, color='blue', linewidth = 3, label = 'line1-dotted',linestyle='dotted')
plt.plot(x2,y2, color='red', linewidth = 5, label = 'line2-dashed', linestyle='dashed')
# Set a title
plt.title("Plot with two or more lines with different styles")
# show a legend on the plot
plt.legend()
# function to show the plot
plt.show().
hope its helpful....
Similar questions