1

I work with QGIS 3.14 and should do an infographic map with pie charts in black and white (grayscales) only. The final result should look something like this.

I tried to use the built in pie chart rendering from layer properties. However, in these pie charts, you can only define a color, but not a pattern fill or similar styling. As I have about 12 different categories, styling them in different shapes of gray makes no sense as the eye can't distinguish the difference between the categories. Each pie, however, has just about 3 or 4 sectors represented (the rest will be styled as "others").

I looked at this workaround, but hope that in the meantime, there is a better solution.

Any idea how I could get a grayscale pie chart?

  • This is a really good idea, and it's a shame it's not a built-in option. You should post to the QGIS mailing lists about it. – JoshC Jul 11 at 23:45
3

You may want to create your own pies using geometry generator more or less below expression and by multiplying the number of geometry generator by the number of class you need e.g

rotate(
make_polygon(
  make_line(
    array_cat(
    array($geometry),
    array_foreach(generate_series(0, to_int(250.36)), make_point(
    x($geometry) + to_real(@radius_length) * cos( @element * (pi() / 180)),
    y($geometry) + to_real(@radius_length) * sin( @element * (pi() / 180)) )
    ),
    array(make_point(
    x($geometry) + to_real(@radius_length) * cos( 250.36 * (pi() / 180)),
    y($geometry) + to_real(@radius_length) * sin( 250.36 * (pi() / 180)) )),
    array($geometry))
    )
), 250.36, $geometry
)

@radius_length is a variable I choose to set a layer level to avoid repeating code. The 250.36 value should be replace with your column value. You will be able then to style with QGIS hatching. We also consider your layer use points. It can work quite well for simple cases but not sure it can fit when you need to manage collision between pies (see screenshot below to illustrate).

Edit: a shorter version could be accomplished using

For first variable

wedge_buffer(center:=$geometry,azimuth:=250.36/2,width:=250.36,outer_radius:=@radius_length)

For second variable

wedge_buffer(center:=$geometry,azimuth:=30 + 250.36 / 2,width:=250.36,outer_radius:=@radius_length)

For third variable,

wedge_buffer(center:=$geometry,azimuth:=250.36 + 30 + 79.64 / 2,width:=79.64,outer_radius:=@radius_length)

Pie chart from geometry generator

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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