1

I've got 50 float number in a variable named v, each one are related to a range between 0 to 10000 with the step of 200.

A sample of the numbers:

print(v[0:4])
[1.90432656848e-05, 0.0014909867739, 0.00886048514416, 0.0131592904038]

I need to display them as a bar chart:

p = plt.bar(range(0, 10000, 200), v)

And here is what I get:

enter image description here

However I'm able to show them using plot:

p = plt.plot(range(0, 10000, 200), v)

enter image description here

So what's that I'm doing wrong?

1 Answer 1

2

Your problem is the width of the bars. The default width is 0.8, so with a step of 200 this is just too thin to display.

You can adjust the width of the bars with:

p = plt.bar(range(0, 10000, 200), v, width=100)

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.