Question
Computer Science Question on Code Optimization
Which of the following is correct code to plot line Chart with dotted linestyle ?
A
plt.plot(x, y)
plt.linestyle = “dotted”
plt.show()
B
plt.plot(x, y)
plt.linestyle | “dotted” )
plt.show()
C
plt.plot(x, y), linestyle - dotted)
plt.show()
D
plt.plot(x, y, linestyle = “dotted”)
plt.show()
Answer
plt.plot(x, y, linestyle = “dotted”)
plt.show()
Explanation
Solution
The correct option is (D) :plt.plot(x, y, linestyle = “dotted”)
plt.show().