# How to add color to vtkUnstructuredGrid vtkTetra data not add color to its point

**URL:** https://discourse.vtk.org/t/how-to-add-color-to-vtkunstructuredgrid-vtktetra-data-not-add-color-to-its-point/8024
**Category:** Support
**Created:** [March 10, 2022, 4:48pm UTC](https://discourse.vtk.org/t/how-to-add-color-to-vtkunstructuredgrid-vtktetra-data-not-add-color-to-its-point/8024 "2022-03-10T16:48:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![xiaoerlaigeid](https://discourse.vtk.org/user_avatar/discourse.vtk.org/xiaoerlaigeid/32/4814_2.png) [@xiaoerlaigeid](https://discourse.vtk.org/u/xiaoerlaigeid)
#### Post date: [March 10, 2022, 4:48pm UTC](https://discourse.vtk.org/t/how-to-add-color-to-vtkunstructuredgrid-vtktetra-data-not-add-color-to-its-point/8024/1 "2022-03-10T16:48:16Z")

</div>

I want to add colour to the vtkTetra itself, not its points. Could anyone give me a example?  
This example is add color to the points [vtk-examples/Cube.py at aa1716a165150f338f6182ce1ac174334f3b9003 · Kitware/vtk-examples · GitHub](https://github.com/Kitware/vtk-examples/blob/aa1716a165150f338f6182ce1ac174334f3b9003/src/Python/GeometricObjects/Cube.py).

---

<div class="post-metadata">

### Author: ![Christos\_Tsolakis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/christos_tsolakis/32/2076_2.png) [@Christos\_Tsolakis](https://discourse.vtk.org/u/Christos_Tsolakis)
#### Post date: [March 10, 2022, 4:54pm UTC](https://discourse.vtk.org/t/how-to-add-color-to-vtkunstructuredgrid-vtktetra-data-not-add-color-to-its-point/8024/2 "2022-03-10T16:54:43Z")

</div>

Just add the scalars to the cells instead of the points, see line 84:

```auto
cube.GetPointData().SetScalars(scalars)

```

should become

```auto
cube.GetCellData().SetScalars(scalars2)

```

where `scalars2` has the appropriate size (the number of cells in `cube`) which is 6 for this example.

---

<div class="post-metadata">

### Author: ![xiaoerlaigeid](https://discourse.vtk.org/user_avatar/discourse.vtk.org/xiaoerlaigeid/32/4814_2.png) [@xiaoerlaigeid](https://discourse.vtk.org/u/xiaoerlaigeid)
#### Post date: [March 11, 2022, 3:49am UTC](https://discourse.vtk.org/t/how-to-add-color-to-vtkunstructuredgrid-vtktetra-data-not-add-color-to-its-point/8024/3 "2022-03-11T03:49:54Z")

</div>

Thanks for your reply. I have another question is how to change the colour in real-time? I want to change the scalar and then make the cube color change in real-time? Are there any similar cases? Thanks !
