In my previous blog post, we talked about using the Color Map Editor panel to set up the color and opacity transfer functions for scalar coloring. In this post, we take a look at color legend in 3D views and controlling the labels shown on the legend using annotations.
Figure 1: Color Map Editor panel showing buttons that affect the color legend
The Color Legend
Figure 2: Color Legend
The color legend, also known as scalar bar or color bar, is designed to provide the user information about which color corresponds to what data value in the rendered view. One can toggle the visibility of the color legend corresponding to the transfer function being shown/edit in the Color Map Editor by using the Show/Hide color legend button near the top of the panel. This button affects the visibility of the legend in the active view.
Figure 2 shows the various components of the color legend. By default, the title is typically the name of the array (and component number or magnitude for non-scalar data arrays) being mapped. On one side are the automatically generated labels, while on the other side are the annotations, including the start and end annotation which corresponding to the data range being mapped.
One can control the characteristics of the color legend using the Edit color legend properties button. The color legend in interactive. One can click and drag the legend to place it interactively at any position in the view. Additionally one can change the length of the legend by dragging the end-markers shown when one hovers the mouse pointer over the legend.
The Color Legend Parameters
Figure 3: Edit color legend parameters dialog
One can edit the color legend parameters by clicking on the Edit color legend properties button on the Color Map Editor panel. This will pop up a dialog that shows the available parameters. Any changes made only affect the particular color legend in the active view.
Besides the obvious changing of title text and font properties for the title and labels and annotations, some of the other parameters that the user can change are as follows: Draw Annotations controls whether the annotations (including the start and end annotations) are to be drawn at all.
When checked, Draw NaN Annotations results in the color legend showing the NaN color setup in the Color Map Editor panel in a separate box right beside the color legend. The annotation text shown for that box can be changed by changing the NaN Annotation text.
Figure 4: Color legend showing NaN annotation
If Automatic Label Format is checked, ParaView will try to pick an optimal representation for numerical values based on the value and available screen space. By unchecking it, one can explicitly specify the printf style format to use for numeric values. Number of Labels is a suggestions for maximum number of labels to show on the legend. Note this is a suggestion and may not exactly match the number of labels shown. To explicitly label values of interest, use the annotations discussed later in this post. Aspect Ratio is used to control the thickness of the legend: greater the number, thinner the legend.
Simply put, annotations allow users to put custom text at particular data values in the color legend. The min and max data mapped value annotations are automatically added, to add any other custom annotations, one can use the Color Map Editor.
Since annotations is an advanced parameter, one has to either toggle the visibility of advanced properties using the gear icon near the top of the panel, or simply search for Annotations in the search box. That will show the Annotations widget, which is basically a list widget where users can enter key-value pairs, rather value-annotation pairs, as shown in Figure 5.
Figure 5: Widget to add/edit annotations on the Color Map Editor panel
One can use the buttons of the right of the widget to add/remove entries. Enter the data value to annotate under the Value column and then enter the text to use under the Annotation column.
One can use the Tab key to edit the next entry. Hitting Tab after editing the last entry in the table will automatically result in adding a new row, thus making it easier to add bunch of annotations without having to click any buttons.
There are two reasons under which annotation texts may not show up on the legend: first, the value added is outside the mapped range of the color transfer function; second, Draw Annotations is unchecked in the Color Legend Parameters dialog (as explained earlier).
The Add active values button can be used to fill the annotations widget with unique discrete values from the data array, is possible. Based on the number of distinct values present in the data array, this may not yield any result (instead a warning message will be shown).
Still to come…
In the next post, we will take a look at categorical color maps.