8

I'm trying to make age-gender pyramids as diagrams placed over centroids of map shapes. Using horizontal histograms I can create the right hand side: enter image description here

And by switching the direction of the bars (from another layer), I can make the left hand side: enter image description here

When both layers are visible, and diagrams are positioned "over centroid" in both layers, I get this result:

enter image description here

I would like to offset the right bars to the right, and the left bars to the left, by placing the y-axis of the diagram on the centroid, so I try to displace the diagrams like this:

enter image description here

However, the diagram position does not change.

How can I offset a diagram in the x-axis by 50% of its own width?

1
  • 2
    Unfortunately, I don't see a simple solution for this - diagrams tend to be not so flexible. You have the option to manually shift individual diagrams using Move a Label or Diagram, see igismap.com/… Maybe this here can help as well: gis.stackexchange.com/a/30617/88814 I would create the bars using geometry generator, where you have the full flexibility.
    – Babel
    Mar 28, 2021 at 16:24

1 Answer 1

7

Solved! (very hacky though)

If my data is like

enter image description here

then the diagram will be centered on the midpoint of the widest bar. However, if I make all the values negative and create one (meaningless) column with a small positive value (1)

enter image description here

then the diagram will be centred on its own y-axis (minus 1 pixel or so).

enter image description here

This is what the assigned attributes for the diagram look like: enter image description here

9
  • Great! Can you explain how you did the settings in the placement tab of the diagrams? This works rather buggy in my case: when I want horizontal bars, it only works if I first close the layer properties and open it again and select it a second time. I was also able to get near to your solution, but not fully, so I would appreciate to learn more about it.
    – Babel
    Mar 28, 2021 at 20:00
  • Look at my result: the red dot is the centroid: i.sstatic.net/5UL9Z.png In some cases it works nice (red arrows), in other cases not at all (red circles). Also not sure where/how you used the fake field for placement.
    – Babel
    Mar 28, 2021 at 20:12
  • 1
    @Babel the offsetting of the centroid where the polygon overlaps the canvas isn’t an issue for me, so long as the two sides of the pyramid sit with their vertical axes on the same point.Have you tried increasing the Priority slider to 100%?
    – grateful
    Mar 29, 2021 at 8:42
  • 1
    As though it were another age grouping. See updated answer with assigned attributes settings. I coloured "fake" to make it match the background as I understand transparency is not possible in a diagram.
    – grateful
    Mar 29, 2021 at 10:06
  • 1
    I found a great video about making multiple diagram types (in Italian): youtube.com/watch?v=vDcyGNqsuSI
    – grateful
    Apr 5, 2021 at 16:19

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.