I want to create a legend next to my map in QGIS. Instead of the classes as legend entries (first picture), I want to add shading as shown in the second one.

I found this workaround "Create a Gradient Color Ramp Legend for Continuous Datasets in QGIS" on YouTube. But is there a smarter way?

enter image description here

enter image description here

How can I do this?

  • What is the data type: raster or vector?
    – ahmadhanb
    Oct 24, 2022 at 21:56
  • is all vektor data @ahmadhanb
    – BAE_23
    Oct 24, 2022 at 21:58

1 Answer 1


I don't think there is a direct way of doing it from a vector layer, however, what you can do is rasterise it, and get the same colour gradient for the raster. You can use this layer's style in the print composer for your key, and hide the key element for the vector layer.

Another approach would be to keep it in vector format, and adapt this tutorial - for rasters for a vector layer. The process is pretty much the same. This was a very quick attempt using a point layer. I haven't put in the indicator lines - If you've used a line layer, this should be really easy.

My very quick version

The divisions on the scale are terrible, I know!

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.