2

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

jorgehumberto
  • 1,047
  • 5
  • 15
  • 33

1 Answers1

3

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.

Community
  • 1
  • 1
Vlas Sokolov
  • 3,733
  • 3
  • 26
  • 43
  • Hi Vlas, thank you for your answer, looks cleaner than my solution. I managed to do what I wanted using polygons, but it is much more cumbersome. – jorgehumberto Mar 02 '17 at 16:26