2

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 May 23 '16 at 4:27
  • added @ahmadhanb – MyGIS May 23 '16 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 May 23 '16 at 4:57
  • Hi @ahmadhanb , I tried the result is the same. – MyGIS May 24 '16 at 2:13
3

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 – MyGIS Jun 2 '16 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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