DEV Community

TechPlygrnd
TechPlygrnd

Posted on

8

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!

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

๐Ÿ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someoneโ€™s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay