0

I have cell array from data set as below.

a = [datetime.datetime(2015, 10, 15, 14, 57, 23, 793), datetime.datetime(2015, 10, 15, 15, 42, 58, 448), datetime.datetime(2015, 10, 15, 15, 44, 46, 892), datetime.datetime(2015, 10, 15, 15, 45, 10, 770), datetime.datetime(2015, 10, 15, 15, 45, 23, 33), datetime.datetime(2015, 10, 15, 15, 45, 53, 582), datetime.datetime(2015, 10, 15, 15, 46, 17, 582), datetime.datetime(2015, 10, 15, 15, 46, 21, 676), datetime.datetime(2015, 10, 15, 15, 47, 1, 246), datetime.datetime(2015, 10, 15, 15, 47, 27, 558)]
b = [5, 4, 5, 4, 6, 5, 4, 5, 4, 6]

plt.plot(a,b,'ro-')

This plots well but I want to show string on map whenever specific number is seen.

e.g. 4--> apple 5 --> mango and 6 --> orange

Is it possible with matplotlib.pyplot?

tmdavison
  • 64,360
  • 12
  • 187
  • 165
maulik mehta
  • 185
  • 2
  • 3
  • 10

2 Answers2

0

looks like annotate is what you want:

Matplotlib: How to put individual tags for a scatter plot

Label python data points on plot

matplotlib scatter plot with different text at each data point

Community
  • 1
  • 1
maxymoo
  • 35,286
  • 11
  • 92
  • 119
  • May be I was not clear in my description. I want to tag number with particular string on y axis. Y -axis should be apple, mango and orange instead of numbers. – maulik mehta Oct 28 '15 at 00:05
0

You can do the by setting the yticklabels

plt.gca().set_yticks([4,5,6]) 
plt.gca().set_yticklabels(["apple", "mango", "orange"])
tmdavison
  • 64,360
  • 12
  • 187
  • 165