
Choosing and managing colors
As colors are used throughout the styling process, we will first review the ways in which you can select and manage color collections in QGIS. The color picker is accessible in any window that allows a color selection to take place. For example, when choosing a color in the Style window under Layer Properties, click on the down arrow next to the color display and then select Choose color..., as shown in the following screenshot:

This will open the color picker tool, as shown in this screenshot:

Let's take a tour of the color picker tool by starting with the components that are always available, and conclude our tour by looking at the four changeable panels.
Always-available color picker components
The current and previous colors are displayed in the bottom-left corner of the color picker tool. In the preceding screenshot, the Old field depicts the color that is currently chosen, and the color mentioned in the Current field will replace the one in the Old field if the OK button is clicked. The current color can be saved in a quick-access color collection (the 16 colored squares in the bottom-right corner) using either of the following two ways:
- By clicking on the button with the blue arrow (
). This will save the current color in the first column of the top row of the color collection, overwriting any existing color. Subsequent clicks on the blue arrow button will store the current color in the next column until all 16 boxes are full and then will loop back to the beginning.
- By dragging and dropping the current color on top of a quick-access color box. The old color can also be saved using the drag-and-drop method.
The color picker displays and allows manipulation of the value in the Current field in two color models: HSV and RGB. In the right half of the color picker, the hue (H), saturation (S), value (V), red (R), green (G), and blue (B) values for the currently selected color are displayed. Each of these color parameters can be individually modified by either using the slider controls or changing the numeric values.
Tip
Red, green, and blue values must be specified between 0
and 255
, where 0
represents no color and 255
represents full color.
Hue is specified in degrees ranging from 0
to 359
, where each degree represents a different location (and color) on the color wheel. Saturation and value are specified using percentages and range between 0%
, representing no saturation or value, and 100%
, representing full saturation or value.
Below the color parameters is the Opacity setting. The right halves of the Current and Old fields display the color with the applied opacity level. For example, in the following screenshot, the current color is shown with no opacity (100%
) on the left and with the currently selected opacity of 50%
on the right. The old color is shown with no opacity on the left and with the previously selected opacity of 100%
on the right (in this case, both sides are the same):

The HTML notation textbox displays the HTML color notation of the current color. The color notation can be changed to one of the four different formats by clicking on the down arrow () in the HTML notation textbox.
Lastly, the Reset button resets the current color to match the old color.
Changeable panels in color picker
The color picker has four changeable panels: color ramp (), color wheel (
), color swatches (
), and color sampler (
). Each of these panels provides convenient ways to select and manage colors. This section will provide the details of each of the four panels.
Color ramp
The color ramp panel is an interactive selection tool that sets the currently selected HSV or RGB parameter values based on the location of a mouse click. To select the color-model parameters that the color ramp will display, click on one of the radio selection buttons next to the H, S, V, R, G, or B values in the right half of the color picker. The selected parameter can be individually modified using the thin vertical slider control on the right-hand side of the color ramp panel. The other two color model parameters can be set simultaneously by clicking on the large color display on the left-hand side of the color ramp panel. In the following screenshot, the V (Value) value in the HSV color model is selected and is represented in the thin vertical slider control; the H (Hue) and S (Saturation) values are combined and are represented in the large color display:

Color wheel
The color wheel panel, shown in the following screenshot, is an interactive selection tool that sets the color value based on mouse clicks. The ring contains the hue, while the triangle contains the saturation and value. To set the hue, click on the ring. To set the saturation and value (while not changing the hue), click on the triangle.

Color swatches
The color swatches panel, shown in the following screenshot, provides an interface to manage color palettes and select colors from the palettes:

To switch between color palettes, select the desired color palette from the drop-down box at the top. The following three default color palettes are listed in the drop-down box:
- Recent colors: This contains the most recent colors selected in the color picker. This palette cannot be modified.
- Standard colors: This contains the colors that are always available as quick selections in QGIS.
- Project colors: This contains the colors that are stored within the QGIS project file.
The three default color palettes can be quickly accessed by clicking on the down arrow next to a color display, as shown in the following screenshot:

The current color can be added to a color palette by clicking on the plus sign button (). The color(s) selected in the palette can be removed by clicking on the minus sign button (
). To apply a label to a color in a palette, double-click on the space to the right of the color swatch, enter the label, and press Enter on the keyboard. The label will be displayed as a tooltip when hovering the mouse over the color in the palette quick-access menu that was shown in the preceding screenshot.
The ellipsis drop-down button to the right of the palette select box provides seven handy functions to manage palettes. Let's review each one:
- Copy Colors: This copies the selected color(s) in the current palette to the clipboard.
- Paste Colors: This pastes the color(s) stored in the clipboard to the current palette.
- Import Colors: This imports colors from a GIMP Palette (GPL) file and places them into the current palette.
Note
A GPL file is a text file that stores color palette information. The GPL file format is from the free and open source GIMP image editor project. More information about GIMP can be found here:
- Export Colors: This exports the current palette to a GPL file.
- New Palette: This creates a new, empty palette that you can name. The palette will persist in the color picker until it is removed.
- Import Palette: This imports a GPL palette file into the list of palettes. The palette will persist in the color picker until it is removed.
- Remove Palette: This removes the current palette from the list. Note that the three default palettes cannot be removed.
Color sampler
The color sampler sets the current color to a color sample collected from the screen using the mouse pointer. The color sample is based on the average of all colors under the mouse pointer within the specified Sample average radius value. To collect a sample color, click on the Sample color button, then move the mouse cursor to a location where you want to sample a color, and either press the spacebar or click to collect the sample. As you move the mouse cursor around, a preview of the sample color will appear under the Sample color button. The following screenshot shows the color sampler with Sample average radius of 5 px
(pixels) and a preview of the green color currently under the mouse cursor:

Now that the color picker dialog has been toured and you know how to select colors and manage them in palettes, we will look at how to create and manage color ramps.
Color picker components available in the Layers panel
For vector layers, the color wheel and recent colors can be accessed through a context menu in the Layers panel. Depending on the type of style applied to the vector layer (vector layer styles are discussed in detail later in this chapter), the color wheel will be accessible in different ways.
If the vector layer has a Single Symbol style, the color wheel can be accessed by right-clicking on the layer name in the Layers panel, then choosing Styles to expose the color wheel and recent colors (shown in the following image):

If the vector layer uses Categorized, Graduated, or Rule-based styles, then the color wheel and recent colors can be accessed by right-clicking on an individual symbol from the expanded layer in the Layers panel (shown in the following image):

With the color wheel and recent colors displayed in the context menu, the color changes you make in the context menu will be changed on the map canvas in real time. To see all the symbol options for the selected symbol or class, click on Edit Symbol.