7

I have a map with graduated symbology, with 328 unique values. I would like to add a legend to my map (as in the picture), illustrating that light blue indicates low values and dark blue high values.

I have done this in ArcGIS before. Is there a way to do this in QGIS as well?

example

1
  • 1
    Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq.
    – underdark
    Commented Mar 26, 2017 at 13:09

3 Answers 3

4

Not sure there's a simple process to achieve this in QGIS, atleast not that I know of.

  • To get a similar legend icon, you can follow this link: Continuous color band for a raster legend in QGIS composer legend.

  • To get the legend to say High or Low, you can achieve this by deleting everything inside the Legend Format textbox and then manually type "High" and "Low" in the symbol containing the maximum and minimum values respectively:

Graduated Legend Format

Composer legend

0
4

Update: Since QGIS 3.18 gradient color band legend items are natively supported for raster layers. As of QGIS 3.28 constructing a gradient legend for vector layers still requires a workaround:

Another workaround is to insert a 'Rectangle' shape with a Gradient Fill using the same color-ramp as your data. Overlay this rectangle over your legend.

Accuracy of this method may not be perfect, particularly if you use transform curves when assigning the color ramp to your data.

Screencap of QGIS Print Composer showing a gradient-filled rectangle overlaid over legend

4
  • I really can't see this option anywhere...and the image inserted in this answer is cropped; so I can't locate what dialog window is open. Can you clarify please? Commented Jul 20, 2023 at 8:11
  • The screenshot is showing a Print Layout window. In Print Layout you can insert shapes (Rectangle, in this case). Note that this answer is outdated, as the functionality is now a core feature of QGIS since v3.18, so you no longer need to use this workaround.
    – TimD
    Commented Sep 2, 2023 at 21:52
  • 1
    I keep seeing comments mentioning that QGIS has this feature now. No, it doesn't. I am running Vesion 3.30 and it doesn't have that feature for vector layers. It only has it for raster layers. Commented Sep 4, 2023 at 6:29
  • A very valid point, thanks for the correction. I'll update the note on this answer. In this case we still need a workaround to show a gradient legend for vector layers. The new Raster Layer gradient legend item provides a new workaround option, so I will add another answer showing that option.
    – TimD
    Commented Sep 5, 2023 at 2:39
0

Raster layers can be configured to display a gradient color-ramp legend. This functionality can be leveraged to create a faux legend to accompany a vector layer. This workaround is more convoluted than the other 'insert a rectangle' workaround, but it does result in a native legend item, which might be preferable in some situations.

For starters, here is my vector point layer styled using a color ramp. This screenshot shows a simple Print Layout consisting of a map and the default legend: enter image description here

Now I add a random raster file to my project. I have added a small GeoTIFF of DEM data. I then set its symbology to use the same color-ramp as the vector layer: enter image description here

Next, in the Print Layout's legend's properties, I can configure the raster layer's legend item with values to make it appear to represent the vector layer: enter image description here

Then I clean up the legend items, renaming the raster layer's entry in the legend, removing the Band 1 sub-title, and removing the My Vector Layer legend item. enter image description here

This results in a print layout like the following. Note that I have hidden the bogus raster layer from the map:

enter image description here

I can also use the Orientation parameter to make it a horizontal legend patch: enter image description here

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.