11

In the past I have just manually matched the color of the border to the color of the fill, but this can be time consuming.

I am wondering, is there any way to have the program automatically match the border color to that of the fill?

The fill color is being assigned through the styling tab in layer properties.

Using QGIS 2.8.6

  • 2
    It seems to me that removing the border will have visually the same effect than matching the border color to the fill (if the border is thin, of course). So you might want to remove the borders ("No pen" option in "border style"). – ArMoraer Apr 25 '16 at 15:43
  • 3
    Thanks for the suggestion, ArMoraer. I have tried that in the past but have found that this usually exposes small gaps between the shapes, which is not aesthetically pleasing. – Kingfisher Apr 25 '16 at 15:59
21

I'm not sure how to enforce it for existing polygons, but you could make it work for any future ones that you create.

In Project Properties>Default styles>Style Manager, you could create your own default symbol style for "Fill":

QGIS Style Manager

Edit the Border color's expression and set it to @symbol_color: Editing the Border expression

Setting the border expression

Lastly, set your new fill style as the default: Setting new fill as default

This will make the border always match the set symbol color. This won't necessarily be reflected in the polygon's properties though. So it can still look like you have a different color border set in the properties, but it should always actually match the object's set symbol color in the map.

Wish I had a better idea as far as making this retroactive, but perhaps I or someone else will come along with a good idea on that later.

  • nice one - just tried this with an existing classified polygon layer and it worked - didn't need to set up a default style either (qgis 2.14.1) – Steven Kay Apr 25 '16 at 19:55
  • Great to hear, Steven! Setting it as a default style would be more to help not have to set it again on any new polygons in the project, but like you said, you don't necessarily have to do that. – JohnR Apr 25 '16 at 20:17
  • 2
    I installed 2.8 and tinkered with it a while. It looks like you'll need to upgrade to 2.14 if the @color_symbol function is super important, there just isn't a built in equivalent in 2.8. – JohnR Apr 27 '16 at 13:47
  • 2
    Stylistically, I like a polygon border that is a slightly darker shade of the fill color. I achieved this by defining the border color expression as: darker(@symbol_color, 200). – csk Jan 18 '17 at 20:19
  • 1
    @RutgerH I was able to get this to work on 2.18.0, but there have been minor styling changes since my initial answer. If you follow the directions and look for "Outline" instead of "Border", you should come to the same conclusion. – JohnR May 24 '17 at 14:51
2

another way to get the border color to match the fill color is to add a new layer to your symbol with the symbol layer type = Outline : Simple line.

When the color is applied at the symbol level all layer get the same color (unless one layer is locked) so the fill and the added border are the same...

enter image description here

0

For how to make it retroactive - you can just save the style as as .qml file, use regular expression find and replace to set the borders to the same colour as the polygons (in Notepad++ or similar):

Find:

<prop k="color" v="([^\r\n"]+)"/>(.+?)<prop k="outline_color" v="([^\r\n"]+)"/>

Replace:

<prop k="color" v="\1"/>\2<prop k="outline_color" v="\1"/>

save, and then reload the style in qgis :)

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.