1

I am rather new to Python 2.7 and Pandas. I have a bar graph and would like to add annotations like mean, variance, etc. I already computed above in the graph. My current graph looks like this:

enter image description here

Along with this line of code:

matplotlib.pyplot.title('All the observation', fontsize=16)
matplotlib.pyplot.annotate( mean, ( 0 , 0), ( 0, 14000), fontsize=16)
matplotlib.pyplot.show()

Does someone have any idea on how to add on the graph the mean etc in a proper and nice way?

Thank you in advance for your help!

Best, Viktor

0

1 Answer 1

1

You could use this:

matplotlib.pyplot.figtext(.6, .8, "Mean = {}".format(mean))

If you have more values to add:

plt.figtext(.6, .8, "Mean = {}\nVariance = {}".format(mean, variance))

enter image description here

Ps. usually matplotlib.pyplot is imported in this way:

import matplotlib.pyplot as plt
Sign up to request clarification or add additional context in comments.

2 Comments

I would also suggest using some string formatting: "Mean = {:.3f}".format(mean) to make the digit display a little easier to handle. I also wouldn't use boxplots, generally, there's a ton of good reasons not to.
Yes thanks it works perfectly! thank you!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.