Will
Will

Reputation: 651

Matplotlib rendering bar graph incorrectly

OK, I've got some data that I'm plotting with matplotlib in python 3.x (it's basically just a csv file with x and y data)

The graph plots fine, except that it ends up with weird bands in it where the spacing between the bars seems to have broken down: enter image description here

I know it's not a problem with the data because I ran a test in excel, and got interesting patterns there as well (though in different places) enter image description here

Please can anybody tell me whether 1) this is something that is already known about, and 2) there is a way of correcting it?

Upvotes: 1

Views: 119

Answers (1)

ImportanceOfBeingErnest
ImportanceOfBeingErnest

Reputation: 339695

This is a problem of stamping in raster images like bmp or png. The structure you want to show (in this case vertical lines) shows features the size of which are on the same order of magnitude than the raster grid (the pixels of the image). This will inevitably lead to distotions.

The option you have is to increase dpi, such that the lines have more pixels to be placed on.

Upvotes: 1

Related Questions