jorgehumberto
jorgehumberto

Reputation: 1097

Matplotlib: plotting marker on edge of line

I want to plot some data, but instead of having the marker centered on the line, I need to have the lower vertex of the triangle aligned with the line. How can this be done?

Here is my MWE:

import matplotlib.pyplot as mplt

data = [1.]*10

mplt.plot(data, 'rv-' )
mplt.show()

Cheers, Jorge

Upvotes: 2

Views: 1378

Answers (1)

Vlas Sokolov
Vlas Sokolov

Reputation: 3913

One way to achieve this is to use a special set of markers defined in matplotlib:

import matplotlib.pyplot as mplt
from matplotlib.markers import CARETDOWN

data = [1.]*10

mplt.plot(data, 'r-')
mplt.scatter(range(10), data, marker=CARETDOWN, facecolor='r')
mplt.show()

Unfortunately, it doesn't render into a triangle as clear as the one in the OP for me. If you're aiming for more visulal clarity, perhaps writing something along the lines of answers to this SO question would be a better option.

Upvotes: 3

Related Questions