# How to dynamically change the color of a point in a point cloud？

**URL:** <https://discourse.vtk.org/t/how-to-dynamically-change-the-color-of-a-point-in-a-point-cloud/10101>\
**Category:** Web\
**Created:** [December 7, 2022, 9:32am UTC](https://discourse.vtk.org/t/how-to-dynamically-change-the-color-of-a-point-in-a-point-cloud/10101 "2022-12-07T09:32:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhangzhi93](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhangzhi93/32/4954_2.png) [@zhangzhi93](https://discourse.vtk.org/u/zhangzhi93)\
**Post date:** [December 7, 2022, 9:32am UTC](https://discourse.vtk.org/t/how-to-dynamically-change-the-color-of-a-point-in-a-point-cloud/10101/1 "2022-12-07T09:32:36Z")

</div>

I added color to the point cloud through the `polyData.getPointData().setScalars()` method. Now I need a hover effect. When the mouse moves over a point, it changes the color of the point. I have obtained the index of the point through the `HardwareSelector` class. How can I set the color of the point independently?

---

<div class="post-metadata">

**Author:** ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)\
**Post date:** [December 7, 2022, 10:35am UTC](https://discourse.vtk.org/t/how-to-dynamically-change-the-color-of-a-point-in-a-point-cloud/10101/2 "2022-12-07T10:35:04Z")

</div>

You need to give your point a specific scalar value, and have in your color table a “hover” color associated with the specific scalar value.

---

<div class="post-metadata">

**Author:** ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)\
**Post date:** [December 7, 2022, 10:36am UTC](https://discourse.vtk.org/t/how-to-dynamically-change-the-color-of-a-point-in-a-point-cloud/10101/3 "2022-12-07T10:36:17Z")

</div>

Alternatively, you can also create a sphere actor that you place onto your moused over point 🙂

---

<div class="post-metadata">

**Author:** ![zhangzhi93](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhangzhi93/32/4954_2.png) [@zhangzhi93](https://discourse.vtk.org/u/zhangzhi93)\
**Post date:** [December 27, 2022, 8:13am UTC](https://discourse.vtk.org/t/how-to-dynamically-change-the-color-of-a-point-in-a-point-cloud/10101/4 "2022-12-27T08:13:34Z")

</div>

I don’t know how to associate “hover” color with the specific scalar value~  
I temporarily created a sphere actor.

Another question, I want to set the color of a point separately. For example, how do I set the 10th point in the point cloud to red? I have an idea now, which is to change the color array, and then set the color for the point cloud again. But is there a simple way to change the color of a point directly.
