# Create a discrete legend

**URL:** <https://discourse.vtk.org/t/create-a-discrete-legend/7787>\
**Category:** Web\
**Created:** [February 7, 2022, 3:30pm UTC](https://discourse.vtk.org/t/create-a-discrete-legend/7787 "2022-02-07T15:30:37Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Rafael\_Scatena](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rafael_scatena/32/7820_2.png) [@Rafael\_Scatena](https://discourse.vtk.org/u/Rafael_Scatena)\
**Post date:** [February 13, 2024, 11:52pm UTC](https://discourse.vtk.org/t/create-a-discrete-legend/7787/13 "2024-02-13T23:52:10Z")

</div>

Hey!

 ![image](https://discourse.vtk.org/uploads/default/original/2X/3/369b3e58b15e6d0d1a6be6bb41f75be068833203.jpeg)

> [@Mapping Scalars into colors](https://discourse.vtk.org/t/mapping-scalars-into-colors/13306):
>
> Hello, I am trying to color the connected components in the image according to their cell scalar value array. The scalarbar renders ok, with the correct labels, but the image renders only with one color. Thank you selectCells-\>Update(); vtkNew\<vtkGeometryFilter\> geometry; geometry-\>SetInputConnection(selectCells-\>GetOutputPort()); geometry-\>Update(); vtkSmartPointer\<vtkPolyData\> geometry\_mesh; geometry\_mesh = geometry-\>GetOutput(); if(geometry\_mesh){ vtkCellData…

---

_[View the full topic](https://discourse.vtk.org/t/create-a-discrete-legend/7787)._
