For a mapping project I am looking for a method how to visualize a polyline where the ends increase in opacity such that it will look like its fades away using QGIS 3.10.10. See the red circle in the picture below.

In essence I am looking to style a polyline the way you would a DEM; with a color ramp that has 0% opacity at the lowest and highest values but instead of measures of height it would be of length. So, like a shape burst fill but for lines, I can imagine I have to play around with the geometry generator.

One solution would be to divide the polyline in several segments at fixed distances and give each segment an increased transparency, however I am looking for a less cumbersome and more robust method.

The result is purely for visual output e.g. the attribute table is not of importance.

Red circle: polyline fade

3 Answers 3


Another possibility is to apply menu processing / toolbox / explode lines and expode the line, i.e. to create a separate line from each line-segment. Now you can color each segment of the original line with a color ramp from transparent to color to transparent, using the id of the exploded lines (i.e. the segment-no. of the original line).

To do that, on the exploded line, change the color to a data driven styly, using the assistant:

enter image description here

In the assistant, set $id (meaning the id of the current feature) as the source, load min/max values (the number of lines/segments). You can change this values manually to adapt the style.

Than apply a color ramp and set the start and end marker to 100% transparency, clicking on the color ramp and changing the markers (you can delete an add markers and change their color):

enter image description here

This gives you the style of the blue line. The yellow line shows the original line with an offset to show the original shape of the line:

enter image description here

If you look close, where the lines/segments touch, they overlap and thus on the transparent parts, you have some darker dots. To remove these, simply change the end cap style from square to flat:

enter image description here

enter image description here

  • Thank you babel also a very cool solution. In the end I marked this as the answer instead of @Erik's which is also a valid solution (!) based on the fact that this was more intuitive for me for visualization purposes with the color ramp etc.
    – MarcM
    Dec 2, 2020 at 14:38

Using the Geometry Generator I was able to create the following:

enter image description here

The idea is to overlay transparent parts of the line over each other, with each substring a bit shorter than the one create before.

This is done by several layers of line_substring($geometry, $length-$length*0.1, $length). line_substring creates a part of the handed $geometry based on starting and end points along the line. This exemplary line only goes from 90% of line length until the end. The next layer could start at 80% of line length, etc.

Depending on your background you might need to do a finer graduation that 10% of line length in order to create a smooth appearance.

  • Thank you Erik, after playing around a bit, this gave me the desired result, as well as a nice example of the geometry generator.
    – MarcM
    Dec 2, 2020 at 12:59

Starting with QGIS 3.20 there is a new option to achieve this. You can use the Interpolated line symbol layer type for vector layers and set a color ramp like transparent/color/transparent.

Screenshot: how to do the settings: enter image description here

Your Answer

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

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