Annotate graph using data from Array
<p>I have a matplotlib graph that I have created using data from arrays. I want to annotate this graph at certain points. The x axis is populated with dates (14/06/12, 15/06/12) etc.. The y axis is price (6500, 6624) etc... I would like to annotate at point: for example (x,y) (14/06/12, 6500). This is my code so far:</p>

<pre><code>Date = ["14/06/12", "15/06/12"]
Open = [6500, 6544]
High = [5434, 5234]
Low = [5342, 5325]
Close = [4523, 2342]
ohlc = []
i = 0
while i &lt; 2:
    Prices = Date[i], Open[i], High[i], low[i], Close[i]
    ohlc.append(Prices)
    i += 1

candlestick_ohlc(ax, ohlc, width=0.8, colorup='g', colordown='r')
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
ax.annotate('Here!', xy=(Date[1], Price[1]))
plt.show()
</code></pre>

<p>This is the current graph and I want the annotation on it where i put it:
<a href="http://imgur.com/a/mv945" rel="nofollow">http://imgur.com/a/mv945</a></p>

<p>Here's a quick example using the matplotlib.pyplot text command to add text to a plot at a specified location:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

plt.figure()
x = np.arange(-5, 5, 0.1)
plt.plot(x, np.cos(x))
plt.text(x=-4, y=0.5, s="Cosine", fontsize=20)
plt.show()
</code></pre>

<p>There are lots of additional formatting options available for text (alignment, font, etc.).  Full documentation is available here:</p>

<p><a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.text" rel="nofollow">http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.text</a></p>

python matplotlib