Bug #980

pshistogram - annotations plotted beneath bar

Added by Andreas 10 months ago. Updated 10 months ago.

Status:ClosedStart date:2016-10-16
Priority:NormalDue date:
Assignee:Paul% Done:


Target version:Candidate for next bugfix release
Affected version:5.2-svn Platform:


When plotting histograms with pshistogram and annotating each bar with the count it represents (-D), parts of the annotation (if wide enough) may plot beneath neighbouring bars. You can increase the bin width (-W) to make the bars wide enough for the annotation to fit, but this is not always desirable.


pshistogram -W2 -D -JX15c data.txt -L1 -Bafg/afg -R0/100/0/60 -F -Gred > histogram.ps

generates histogram.ps using data.txt.
Using GMT 5.2.1 (r15220).

data.txt Magnifier (8.03 KB) Andreas, 2016-10-16 22:05

histogram.ps (25.2 KB) Andreas, 2016-10-16 22:06

Associated revisions

Revision 17220
Added by Paul 10 months ago

Delay plotting of -D labels until all bars have been drawn, addressing issue #980


#1 Updated by Paul 10 months ago

  • Status changed from New to Feedback
  • Assignee set to Paul

You can rotate the annotations with -D+r and then, depending on font size and bar width, they are not covered up. However, there is obviously some limitation here depending on desired font, magnitude of the counts, and the physical width of a bar in your projection. I can delay the plotting of the labels until all the bars are plotted [right now each label is plotted after each bar, leading to the masking]. That would eliminate the masking out of the strings but of course they would still overlap onto neighboring bars. Is this an OK solution? Did you have any particular suggestion on how to make this better?

#2 Updated by Paul 10 months ago

  • Status changed from Feedback to Resolved
  • % Done changed from 0 to 100

I went ahead and implemented the delayed labeling. In r17220. Other than change font size, rotated etc I think we have no other ways to handle this situation.

#3 Updated by Andreas 10 months ago

Sounds good, Paul. I think this is good solution. You should be prepared to change font size, rotation etc. to make a good plot, but you should never see your annotation masked by it's own data!

#4 Updated by Paul 10 months ago

  • Status changed from Resolved to Closed

Closing this as fixed.

Also available in: Atom PDF