2

Is it possible to show the values on top of each bar of a histogram created with QGIS? (I am using QGIS 2.18)

enter image description here

I know this post [Is it possible to label bar charts? addressed a similar question years ago, but it was unanswered, and maybe the program has evolved since, or someone has find a better solution.

2 Answers 2

4

I'm using QGIS 3.4, but this answer should also be possible in 2.18.

Unfortunately it doesn't look like there's a way to directly display the histogram values as part of the histogram. A workaround is to add field values as labels, and manually adjust the placement settings until they line up with the corresponding part of the diagram.

For example, I used multi-line labels with a horizontal histogram. It should be possible to this in any orientation, though.

enter image description here

As you can see the labels aren't perfectly aligned, but I set this up in just a few minutes. You can achieve better alignment with trial and error.

Use the concat() function to concatenate the fields into one long string separated by any one character. Then use that character as the line separator.

enter image description here

Label placement: offset from centroid. Use trial and error to figure out the best values for X,Y Offset (I used X: -3mm, Y: -7mm).

enter image description here

The diagram is right-oriented (layer diagram properties window > options tab)

enter image description here

with default-width bars (5mm) and with scaled size with a bar length of 10.

enter image description here

Diagram placement is "Around centroid".

2
  • Great explanation! As you say it is not the answer to the question but a very good workaroud. Thank you so much!!
    – Pescariz
    Jan 18, 2019 at 9:17
  • 1
    This seems like a feature worth requesting. I did a quick search of the bug report/feature request site, and it doesn't look like anyone requested this feature yet.
    – csk
    Jan 18, 2019 at 16:13
1

there is a similar way to do it with vertical chart orientation and numbers on top. enter image description here

place your labels with an "offset from centroid" and define the "Offset X,Y' via individual expression (the sum symbol at the right side of those two fields for x and y). in my case the expression was like this

'7,' || to_string( "FIELD_01" *-7)

'Offest X,Y' expects a string like this 'nn,mm' to move objects in x nn meters and in y mm meters.

"FIELD_01" ... the field with values from yellow columns. the expression at the right side multiplies the field-values by -7 to move them up according to max(FIELD_01)-values. this specific value -7 was identified by try and error ...

|| .... concatenates the x offset value and the epression for the y offset value.

units must be set to "Map Units" !!!

(grey bars are part of another experiment and should not be considered in this context !)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.