How do I add these tiny dots at the end of line plots in matplotlib?

Viewed 864

I am trying to add these tiny bubbles at the end of line plots. How to do that in matplotlib?

enter image description here

2 Answers

You could try with plt.plot.markevery:

import numpy as np
import matplotlib.pyplot as plt
delta = 0.11
x = np.linspace(0, 10 - 2 * delta, 200) + delta
y = np.sin(x) + 1.0 + delta


plt.plot(x,y,'o',ls='-', ms=8,markevery=[-1])

Output:

enter image description here

Another way to do this (on top of the solution present by @MrNobody33) is to superimpose line graphs and scatter plots. That way, if you have specific values you want to showcase, you can add them to the scatter plots.

Code Example

import matplotlib.pyplot as plt

# Show the Lines
plt.plot([0, 10], [0, 10], color='b')
plt.plot([2, 7], [0, 3], color='r')

# Show the endpoints using Scatter plots
plt.scatter([10], [10], color='b')
plt.scatter([7], [3], color='r')

# show the graph
plt.show()

enter image description here

Related