Feature request #12693

option to have the label color automatically match the polygon color

Added by Cris Jesse over 8 years ago. Updated over 7 years ago.

Pull Request or Patch supplied:No Resolution:fixed/implemented
Easy fix?:No Copied to github as #:20799


Sorry if this is already available, I couldn't find anything for it. I have projects that come up from time to time that include either a large volume of shapefiles, or a shapefile that we have to edit the style to categorized and classify into a large number of sets (one last week had over 1400 of them in one project). When we do this we end up with a log of polygons, each set having it's own color as it should.

When we go to work with it on the map, sometimes it can get a bit crowded with all the different Labels. Since all the labels are the same color, it can be hard to tell which areas are for which sets (we rely heavily on knowing the label names in these cases).

Can an option be added that would make the label colors automatically match the polygon colors? This would be very helpful!

Please let me know if anyone has any questions on what's being requested.


color-pick_qgis.png - where to put "label color based on polygon color" option (89.9 KB) Cris Jesse, 2015-05-07 02:17 PM


#1 Updated by Cris Jesse over 8 years ago

Ideally we would still want to be able to edit other parts of the label formats as well, such as size, adding shadow, etc... We wouldn't want the solution to remove the ability to also change those parts of the format, if at all possible.


#2 Updated by Harrissou Santanna over 8 years ago

Wouldn't it be hard to read red label on red polygon, yellow label inside yellow polygon and so on...?

Do you know that you can set how labels must show using the "data defined override" properties? You "just" have to add appropriate fields to your shapefile. But I think the plugin EasyCustomLabelling may help in that way. You should give it a look.

#3 Updated by Cris Jesse over 8 years ago

Adding in shadows, backgrounds, buffers, etc would take care of not being able to see the matching colors.

I did install the EasyCustomLabelling plugin, but I'm not seeing it anywhere (or any different options). I'm on QGIS 2.8.1.

Not sure I understand how to pull the color of the polygon into the "data defined override" properties. Where would I get the color data for each polygon from to enter here? I can understand if I only have a couple how to do it one by one, but when I've got 1400 colors to match up...?

#4 Updated by Cris Jesse over 8 years ago

I was able to find the EasyCustomLabelling, but I still could not figure out how to pull the colors from the project-defined polygon and use them to automatically match the colors for the labels.

#5 Updated by Harrissou Santanna over 8 years ago

Did u set your color manually? all 1400? wouaw...
I don't think There is currently a graphic way to automatically match labels color with the one defined manually in the style properties, unless python or xml skills...

What I was thinking about, with data defined feature, is to fill a field in your shape with a rgb value for each (category of?) polygon. And then select this field through "data defined override" tool to set style or label color value. And later, all you'll have to do if you want to update color is to change the value in the field. But I don't know how will legend look like...

EasyCustomLabeling plugin creates a new label file containing values from polygon file and adds to it new fields to design color (color, font, size, alignment, visibility...). The value set in those fields will be applied to the label automatically, this is why I proposed it.

Maybe, if needed, this discussion should continue in the user mailing list to not flood your pertinent feature request with support matters.

#6 Updated by Cris Jesse over 8 years ago

lol, thankfully no I did not set all those colors manually. I simply went to:

Layers Properties
> Style (tab)

Categorized (from top dropdown menu)

Chose the column to sort by (from 2nd drop down menu)

Clicked Classify

I will google more on how to use the EasyCustomLabelling plugin to see if I can find a workaround there, but so far I have had no luck pulling those colors from any files to insert into the Labeling section so that the polygon and label colors match up.

#7 Updated by Giovanni Manghi over 8 years ago

  • Status changed from Open to Feedback

In general seems to me that this request would be better fitted for a plugin rather than a tool available directly in QGIS.

#8 Updated by Cris Jesse over 8 years ago

I honestly don't know enough to know where to draw the line between where plugin vs direct functionality lies. I've attached a screenshot of where I see this being put in (as an option just below the cursor in the dropdown color box). In my non-developer (and still somewhat novice) opinion this would be best inserted directly where it would be used, right in the color dropdown box.

The functionality would probably be helpful for any of the color options in the label section (text, buffer, background, shadow).

#9 Updated by Jürgen Fischer over 8 years ago

  • Status changed from Feedback to Open

#10 Updated by Nyall Dawson over 7 years ago

  • Status changed from Open to Closed
  • Resolution set to fixed/implemented

This is now possible by setting the label (or buffer, shadow, etc) color to the expression "@symbol_color"

#11 Updated by Cris Jesse over 7 years ago

Great, thanks!!

Also available in: Atom PDF