0

I am trying to use ggplot in Python for the first time and the semantics are completely unobvious to me.

I have a pandas dataframe with two columns: date and entries_sum. What I would like to do is plot a bar plot with the date column as each entry on the x-axis and entries_sum as the respective heights.

I cannot figure out how to do this with the ggplot API. Am I formatting my data wrong for this?

2
  • Need more information to give a good answer, e.g. what code did you try for your plot, and what was the result/error. Also, have you looked at the ggplot docs? Commented Jun 17, 2015 at 21:03
  • Yes, I have. The issue (as mentioned below) was that I thought 'identity' was the default parameter for stat for geom_bar. However, it doesn't work without it explicitly stated. Commented Jun 17, 2015 at 22:12

1 Answer 1

1

How about:

ggplot(aes(x='date', y='entries_sum'), data=data) + geom_bar(stat='identity')
Sign up to request clarification or add additional context in comments.

2 Comments

So, this was it, obviously. I thought that 'identity' was the default parameter for stat, so I had not put it in any of my attempts.
Indeed the documentation for the Python version of ggplot is not mature yet so takes a little testing to get it right.

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.