Easy tip: How to use different color labels in a layer

Easy Tip: Using different color labels in a layer
64-bitIn this example we will assign a red label color for all states with a population of more than 10,000,000 within the table “USA” and the rest of the labels are assigned a black color.

This can be easily done if we separate the layer into two, overlay them and set their respective label and layer properties. For the first step we need to query the data.

Perform following query and set its alias name 

Query required records
Figure 1: Query required records

Open a Map window for main table and the query table. Enable the Automatic Labels option for both the layers. At this point all of the labels have the same properties. 

Map window with main and query layer
Figure 2: Map window with main and query layer

Now open the Layer Properties dialog for the USA_pop (the query) and set the label display color to red (Figure 3). Then set its label fit and density to “Try other Positions” under the Labeling Rules tab (Figure 4). This setting allows MapInfo Pro to use an algorithm to fit more labels on the map. 

Set label display properties for query layer
Figure 3: Set label display properties for query layer 

Set label rules for query layer
Figure 4: Set label rules for query layer 

Now set the Label Fit and Density labeling rules for the USA layer (the main table) to Discard Label. This setting will discard the main table’s label wherever it overlaps with the label from the query table. 

Set label rules for main layer
Figure 5: Set label rules for main layer 

Additionally, set the label priority so that the Query layer labels are always viewable. For this, right click on the map in the Workspace Explorer (or Layer Control). See figure 6. Move the query table so that it is above the main table (Figure 7). This means the labels from the query are a higher priority than those of the main table. 

Set label priority
Figure 6: Set label priority 

Set label priority 
Figure 7: Set label priority 

And here is the final output 

Desired output
Figure 8: Desired output 

The techniques in this article, including setting label priorities, using an SQL query as a temporary layer in your map and setting alias names for query tables for better identification have many other uses. Be sure to keep these in mind as you use MapInfo Pro.

For additional labeling techniques that use expressions, check out this article named "Using expressions for labeling" on community. 

And finally, for a very advanced method of labeling your maps through the use of conditions, you can search for article named "Conditional Labeling with MapInfo Professional" on community.

Article by Piyush Mahajan, Data Development, Noida
When not writing articles for the MapInfo Professional journal, Piyush loves to explore ways to innovate with diverse geospatial data and its utilization, is learning life coaching skills, and enjoys cooking.
UPDATED:  July 6, 2017