# Cell Coloring

**URL:** https://discourse.vtk.org/t/cell-coloring/12996
**Category:** Support
**Tags:** python
**Created:** [January 3, 2024, 10:24am UTC](https://discourse.vtk.org/t/cell-coloring/12996 "2024-01-03T10:24:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Mordrago](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mordrago/32/8974_2.png) [@Mordrago](https://discourse.vtk.org/u/Mordrago)
#### Post date: [January 3, 2024, 10:24am UTC](https://discourse.vtk.org/t/cell-coloring/12996/1 "2024-01-03T10:24:48Z")

</div>

Hello!  
I developed code that color selecting cells, code belowe:

```auto
        self.polydata = polydata
        self.colors.SetNumberOfComponents(3)
        self.colors.SetName("Colors")

        default_color = [255, 255, 255]

        self.colors.SetNumberOfTuples(self.polydata.GetNumberOfCells())
        self.colors.FillComponent(0, default_color[0])
        self.colors.FillComponent(1, default_color[1])
        self.colors.FillComponent(2, default_color[2])
        # self.colors.SetTuple(1, [0, 255, 0])
        self.polydata.GetCellData().SetScalars(self.colors)
"""Some Code of vtkselector"""
                for j in range(num_cell_ids):
                    cell_id = cell_selection_list.GetValue(j)
                    self.colors.SetTuple(cell_id, [0, 128, 0])

                self.polydata.GetCellData().SetScalars(self.colors)

```

And this work, i using vtkHardwareSelector to pick cells ids.

But i have another part of code where i pick cells via frustrum, and want to color them, they do not color. I also tried to color them without picking cells, i just wanted to color cells from 1 to 100, but i also dont work. Where could be a problem?

---

<div class="post-metadata">

### Author: ![Mordrago](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mordrago/32/8974_2.png) [@Mordrago](https://discourse.vtk.org/u/Mordrago)
#### Post date: [January 3, 2024, 2:44pm UTC](https://discourse.vtk.org/t/cell-coloring/12996/2 "2024-01-03T14:44:25Z")

</div>

I find solution by myself. Each time when i want to colors cells i need to set scalars to none.

```auto
self.polydata.GetCellData().SetScalars(None)

```
