3

If you look closely at a legend in the QGIS Print Composer, you'll see that each colour box has a hairline (1 px) border. How can I remove these borders?

By playing around with the settings, I've worked out that this colour matches the font colour setting.

example showing hairline borders

In this case the map background is black, so the only way to get rid of the border is to set the font colour to black.

However, doing this hides the labels. Black text on a black background... bit difficult to read!

I've found a (hacky) way to get around this, by

  • duplicating the legend (copy/paste)
  • set its background to transparent
  • set the font colour to black
  • set all items' text values to space (it wont let me enter an empty string)
  • remove any legend title etc.
  • drag it on top of the original legend, so that the boxes line up

However, this is a bit of a hassle, especially if there are lots of legend entries.

Is there a better way to do this?

EDIT

As of version 2.18 (or maybe earlier) this can now be controlled using a setting in Print Composer. See answer below.

  • 1
    Are we talking here about legend for grids / rasters? Because for polygons it is all about how you set the outline of polygons. – Miro Sep 6 '15 at 1:07
  • these are for elevation breaks in a raster. I see what you mean about the polygons, setting a transparent outline works there. – Steven Kay Sep 6 '15 at 9:14
  • Yes, in worst case you can use that as another workaround. Not sure if there is some settings for grid boxes in the legend, I am always happy with the frame it makes around. – Miro Sep 6 '15 at 23:18
  • 1
    @Miro - You should post your comment as an answer as it does provide an alternative solution which others could find useful :) – Joseph Sep 7 '15 at 10:34
3

Update: As of QGIS 2.18 at least, there's now an option to uncheck the Draw border for raster symbols in Print Composer - please see the other answer for details

As I mentioned in the comment, there is another workaround - create dummy polygon layer where the outline of boxes in the legend can be set through style of the polygons. It would be definitely way easier to set directly the outline properties in raster legend, but because there is no such option currently as far as I know, workaround is needed.

For color map use:

  1. create dummy polygon layer
  2. create two simple polygons with 1 column - value
  3. set your raster legend minimum for one polygon, raster legend maximum for second
  4. switch the single symbol to Graduated, make same number of classes as with raster legend
  5. input into legend raster legend values
  6. change symbol outline to whatever you like

enter image description here

For custom colors one polygon is enough, no values needed. All you need to do is to switch style of polygon layer to Categorized and add your custom categories.

If you want more options for raster legend, I would suggest to try your luck as feature request on:

http://hub.qgis.org/projects/quantum-gis/issues

Or you can get involved your self into either sponsoring this feature or get into development. Though it might sound like a lot of hassle, it is more systematic solution.

4

an update to this. As of QGIS 2.18 at least, I noticed there's now an option to uncheck the Draw border for raster symbols in Print Composer:-

enter image description here

Left checked (the default), you can style the outline. Left unchecked, the outline vanishes :)

I'm not sure exactly which version introduced this, but thank you to whoever implemented this!

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.