DEV Community

TechPlygrnd
TechPlygrnd

Posted on

Matplotlib Tutorial #3: Plot Without Line

In the last blog we already created a plot, but perhaps you only want the figure to show points not with lines, how can you do that? In this blog, I will show you how to do just that.


Plot Without Line

In the Matplotlib plot, you can create a plot without the line. Let me show you how to do it.

First, let us create a normal plot with a line

import matplotlib.pyplot as plt
import numpy as np

xpoints = np.array([0, 6])
ypoints = np.array([0, 250])

plt.plot(xpoints, ypoints)
plt.show()
Enter fullscreen mode Exit fullscreen mode

In order to make a plot without the line, you just need to pass o as the third argument to the plot method

import matplotlib.pyplot as plt
import numpy as np

xpoints = np.array([0, 6])
ypoints = np.array([0, 250])

plt.plot(xpoints, ypoints, 'o')
plt.show()
Enter fullscreen mode Exit fullscreen mode

If you run the above code, you will get the following output result

Matplotlib plot


That is it! that is how you can create a plot without the line. Thank you for reading this blog and have a nice day!

Top comments (0)