janpipek / physt

Python histogram library - histograms as updateable, fully semantic objects with visualization tools. [P]ython [HYST]ograms.
MIT License
129 stars 15 forks source link

Wrong bars center in polar_map #54

Closed ruhugu closed 5 years ago

ruhugu commented 5 years ago

I have found that the bars in polar_map are centered on the left edge of the phi bins instead of their center. Because of this, the representation of the histogram does not coincide with the data, as in the figure below: polarmap_wrong

I think this can be easily solved by replacing

bars = ax.bar(phipos[i], dr[i], width=dphi[i], bottom=rpos[i], color=bin_color,

with

bars = ax.bar(phipos[i] + 0.5*dphi[i], dr[i], width=dphi[i], bottom=rpos[i], color=bin_color,

in the definition of polar_map.

By the way, thank you for this amazing package!

janpipek commented 5 years ago

Hi Rubén,

thanks for reporting! I wonder how this could happen. I am almost sure that at the point of implementing, this worked correctly. Don't know if I changed something later or if matplotlib changed its defaults :-(

In any case, the align='edge' keyword argument solves this issue.

Hope the patched version (already on pypi) works for you too.