I have created a heatmap from points layer's style property. However when I add a legend to the print composer I do not get anything in the legend except the layer name, how can I add the color ramp besides the layer name?

enter image description here

  • Can you add a screenshot of the problem? It will help a lot.
    – ahmadhanb
    Commented May 23, 2016 at 4:27
  • added @ahmadhanb
    – GforGIS
    Commented May 23, 2016 at 4:48
  • Try to load the heat map on a new QGIS project file without OpenStreetMap. Then, use composer manager to create a new layout, and see if this can solve your problem.
    – ahmadhanb
    Commented May 23, 2016 at 4:57
  • Hi @ahmadhanb , I tried the result is the same.
    – GforGIS
    Commented May 24, 2016 at 2:13

1 Answer 1


What you can do is create a proxy layer to act as the legend styling.

Being a little creative what you can do is create a new polygon layer with a couple of random shapes. Create the shapes away from your maps focus area because using transparency to hide them will negate this exercise and not show anything in the legend.

In the attributes table of the random shapes layer you can use the ID as a value in the table ($ID in field calculator) just to give it some scaling values, if you've got 2 shape make sure one is higher than the other. Now use a gradient style on the layer.

Match the gradient colour to your heatmap. Under "Symbol" remove the border style, which will give a smoother gradient impression. Under the "Classes" tab set around 7 - 11. This will give a nice resolution to the gradient in the legend but too many will create quite a large legend item. "Classify" and sort the value in descending order, this will put the darkest colours to the top. Using the invert option will reverse the colour order but it won't match your heatmap!

Now edit the legend labels. There are too many labels to show on gradient so delete the majority. Using an odd number of classes allow for a lowest, highest and middle label. But if you don't need/want the middle label then feel free to change the classes to a even number. Change the labels to also match the values on your heat map.

In the map composer legend properties, hide the heatmap layer and rename the new random shapes layer as the heatmap.

Under "Symbol" set "Symbol Height" to 3.00mm. Under "Spacing" set "Symbol Space" to 0.00mm. This gets the symbols as close as they can possibly get. If the legend is too large you'll have to remove some of the classes but you lose the gradient effect. More classes will improve the gradient whilst lengthening the legend item.

enter image description here

  • It is not straightforward but it is a good workaround
    – GforGIS
    Commented Jun 2, 2016 at 14:16
  • @MyGIS is there any other way to do this in the current versions of QGIS?
    – GeorgeC
    Commented May 11, 2021 at 2:33
  • @GeorgeC I haven't touched that map since 2018, let me check it out for you.
    – GforGIS
    Commented May 11, 2021 at 4:10
  • Thanks - I can create a new question but SE usually prefers asking for an update when it's just seeing if new versions can answer the question better.
    – GeorgeC
    Commented May 12, 2021 at 1:51
  • can i know the step, it not clear for me Commented Aug 8, 2021 at 11:45

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.