Gradient arrows

Today’s post was motivated by a question following up on my recent post “Details of good flow maps“: How to create arrows with gradients from transparent to opaque?

gradient_arrow

The key idea is to use a gradient fill to color the arrows:

gradient_arrow_settings

It all seems perfectly straightforward: determine the direction of the line and set the gradient rotation according to the line direction.

But wait! That doesn’t work!

The issue is that all default angle functions available in expressions return clockwise angles but the gradient rotation has to be set in counter-clockwise angles. So we need this expression:

360-angle_at_vertex($geometry,1)

Happy QGISing!

Advertisement
12 comments
  1. Bill said:

    Very beautiful Anita. Do you think a variable gradient line width is an implementable idea? For instance, when depicting river flows between two gauges, to illustrate the relative change in volume going downstream and gaining inflows, could the line width increase between two end vertices?

    • Thanks Bill! The arrow line start width and end width can be configured separately in arrow symbol layers. I think that should do what you want.

  2. Great work! I also bought the book QGIS Map Design, so thanks for all your efforts.

    I have one question though; how did you get to make the flow arrows curved instead of straight lines?

    • Thank you! The arrow symbol layer settings contain a “curved arrow” option. To draw a curved arrow, the line needs to have one intermediate point between start and end. Depending on the intermediate point’s position, the line is more or less curved.

  3. lucio said:

    your site is very useful! many thanks! one question: the first color of the gradient is ALWAYS at the end of the arrow? in my map it seems this rule is not applied :-(

    • The rule is same for all arrows. Check if all settings, particularly the reference point settings, are set up as shown in the screen shot.

  4. Alice said:

    Thanks for this tuto ! I’ve got a problem with the angle expression -but maybe it’s because of 8.2 version I’m actually using- it returns error “unexpected ‘(‘ expecting $end”. Have you got a solution so my fill could have a logical way (origin-destination)
    Thanks a lot

  5. Alice said:

    oupsi, rotation expression*

%d bloggers like this: