0

If I feed several x/y sets to matplotlib.pyplot.plot, how does annotate decide how to correlate the xy value to one of the sets? Is there an assumption that all the sets are scaled the same way?

 plt.plot(clist, plist, 'g', clist, rlist, 'r', clist, flist, 'b')
 plt.annotate("%d chars F=%f" % (threshold_c, threshold_f), xy=(threshold_c, threshold_f),
             xytext=(-50, 30), textcoords='offset points',
             arrowprops=dict(arrowstyle="->"))

We seem to have a good answer, but someone asked for clarification.

Calling annotate with the default xy= has the effect of associating an annotation with a graphed x/y pair. When there's one X array and one Y array, it's obvious to me what that means.

With multiples, I didn't know if plot was going to automatically set up multiple sets of axes, one for each X/Y array -- and, if so, how annotate was going to work. The answer explains that one call to plot creates one set of axes that scales all the X/Y sets as best it can, and so annotate knows where to go.

3
  • 2
    What do you mean by "goes with a call"? You did directly give annotate a point xy, and that's where your label will go, no matter what you did with plot earlier. Commented Jul 9, 2010 at 12:34
  • But what if the three data sets are differently scaled? In my actual case, they aren't, so the code I posted worked. Is my confusion that you can't pass multiple sets to one call to plot if they are not on the same scale? Commented Jul 9, 2010 at 14:29
  • 1
    Can you reformulate your question in somewhat higher-level terms of what you want to accomplish? All that the annotate function does is draw some text and an optional arrow at the coordinates you give. It does not "correlate" the value with anything. Commented Jul 11, 2010 at 14:27

1 Answer 1

2

You should think of annotate as associated with the axes and not the data. Multiple data sets can be plotted on the same axes, as in your example, or you can have different axes in the same plot, but then when you use annotate, etc, you'd want to specify which axes you wanted to annotate.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.