31 Years of Python | 48 Hour Sale Extension!!!

Ever seen ValueError invalid value of type float64 for bargap property of layout

Screen Link:

My Code:


What I expected to happen:
Three plots

What actually happened:
Two plots and then :

ValueErrorTraceback (most recent call last)
<ipython-input-1-d74052949946> in <module>()
      2 plt.show()
      3 wnba['Height'].plot.hist(title='Height')
----> 4 plt.show()
      5 wnba['MIN'].plot.hist()
      6 plt.show()
    Invalid value of type 'numpy.float64' received for the 'bargap' property of layout
        Received value: -2.842170943040401e-14

    The 'bargap' property is a number and may be specified as:
      - An int or float in the interval [0, 1]

Hi @ananth.ch,

I had the code below in this mission. Without a plt.show(), it gives the plots as output. But adding plt.show() gives the same error message. But at least you can observe the three plots and answer the question in the mission.

fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize = (10,15))

Since the bargap value is a negative number close to zero, which means the bars are overlapping each other just a little, and the bins defaults to 10, I’m guessing this error message is figure&plot size related. Maybe DQ env has a limit on the display which forces the plots to cram a little. One way to experiment is to change the number of bins and see if the error message persists and the bargap value too.

Since googling didn’t work, I’m inclined to believe it’s a DQ thing… Please let me know if you find out more.


Hi Vera!
Thanks for collaborating. That’s a nice workaround. Thanks!

1 Like

Maybe arriving a bit late to the discussion, but I had the same issue in the DQ project on Bike Rentals.

What solves the issue for me was adding %matplotlib inline to the library initializations. Of course this should be added when working with plots in Jupyter Notebooks. However, I also think this is a DQ thing as the error trace only led me here. So hopefully this suggestion can save anyone a few minutes.

I ran into the same issue for the same screen as the original poster. What worked for me (in line with the suggestion of @veratsien ) is to change the number of bins, which I had to do for both Height and MIN actually. The following code ran without error:

wnba['Age'].plot.hist(title = 'Age')
wnba['Height'].plot.hist(title = 'Height', bins = 12)
wnba['MIN'].plot.hist(title = 'MIN', bins = 12)

Dataquest (maybe @Sahil ?), you may want to check this post. As it seems a bit odd to run into this issue.


Hi Jasper,

It seems to be an issue with the platform. It’s good that you found a workaround to the problem. However, could you please also report the issue to the Technical Support Team of Dataquest? Just click the ? button in the upper-right corner of the platform screen where you detected this issue, describe the problem, and click Report an Issue. Thanks!

Done! :slight_smile:

(Aware of the reporting mechanism for bugs, which I use for any new bugs that I run into. For this one that was described here already, I still added my info here; also as that may be helpful for other learners. (So that raises this question: if I report a ‘bug’, can other learners actually then see it on a ‘known bug’ list on the page, until it is fixed…?)

1 Like

Hi Jasper,

Previously, we had a special category in the Community dedicated to the known bugs. I guess that since those times, they were all resolved! :grinning: Now, the Community is strictly oriented to the data-related technical questions, projects, and additional resources. The members of the Support team almost never use the Community anymore, everything is being reported and fixed exclusively through the ticketing system, so reporting the bugs or even discussing them in the Community became totally useless at some point.

About the ability of other learners to see if the bug has been already reported: well, I don’t really think that they care about it :stuck_out_tongue_winking_eye: The only thing that a user wants when they report a bug is that it’s resolved, and preferably asap. And the Dataquest Support Team is doing their best to resolve all the reported technical issues asap, only that it can happen that some issues are harder to resolve than the others, require more time, are recurrent, etc.

Having said that, you can find useful the status dashboard of Dataquest. Also, I’d strongly suggest to you and to all the other learners to report any detected bug anyway, even if you’re sure that it has been already reported by many users. The more users report the same bug the better because, for the team, it will be an indicator of a possible emergency happening on the platform, so they can prioritize their tasks and fix the urgent issues first.

All clear - thank you for the elaboration!

1 Like