# Display scalar value on points

**URL:** https://discourse.vtk.org/t/display-scalar-value-on-points/15054
**Category:** Support
**Tags:** python
**Created:** [December 20, 2024, 3:43pm UTC](https://discourse.vtk.org/t/display-scalar-value-on-points/15054 "2024-12-20T15:43:49Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Julien\_Champagnol](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julien_champagnol/32/9415_2.png) [@Julien\_Champagnol](https://discourse.vtk.org/u/Julien_Champagnol)
#### Post date: [December 20, 2024, 3:43pm UTC](https://discourse.vtk.org/t/display-scalar-value-on-points/15054/1 "2024-12-20T15:43:49Z")

</div>

I, I’d like to display scalar values on points but it gets displayed on cells  
Here is is my code :

```auto
def setMeshVertexAttribute(self, id, name):
        reader = self.get_object(id)["reader"] # reader is a vtkXMLGenericDataObjectReader
        points = reader.GetOutput().GetPointData()
        points.SetActiveScalars(name)
        mapper = self.get_object(id)["mapper"] # mapper is a vtkDataSetMapper()
        mapper.ScalarVisibilityOn()
        mapper.SetScalarModeToUsePointData()
        mapper.SetScalarRange(points.GetScalars().GetRange())
        self.get_protocol("vtkWebPublishImageDelivery").imagePush({"view": -1})

```

Any idea what might be causing this?

Thanks

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 20, 2024, 10:16pm UTC](https://discourse.vtk.org/t/display-scalar-value-on-points/15054/2 "2024-12-20T22:16:21Z")

</div>

Hello,

You need to align your scalar data with the vertexes, but we need you to tell which dataset you’re using (`vtkUnstructuredGrid`, `vtkPolyData`, etc.).

best,

PC

---

<div class="post-metadata">

### Author: ![BotellaA](https://discourse.vtk.org/user_avatar/discourse.vtk.org/botellaa/32/1243_2.png) [@BotellaA](https://discourse.vtk.org/u/BotellaA)
#### Post date: [December 21, 2024, 7:41am UTC](https://discourse.vtk.org/t/display-scalar-value-on-points/15054/3 "2024-12-21T07:41:11Z")

</div>

Hi,

Thanks for the reply.

It works when we display the scalars on the polygon vertices with interpolation on the polygons but we cannot manage to display the same scalar data on the points only.

The data is a Polydata made of triangles.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 21, 2024, 1:44pm UTC](https://discourse.vtk.org/t/display-scalar-value-on-points/15054/4 "2024-12-21T13:44:59Z")

</div>

Which class? `vtkPolyData`?

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [December 21, 2024, 2:50pm UTC](https://discourse.vtk.org/t/display-scalar-value-on-points/15054/5 "2024-12-21T14:50:07Z")

</div>

> [@](#):
>
> with interpolation on the polygons

That’s the way VTK handles point scalars by default, it’s not possible to use scalars to color the points but not the faces.

The only way to avoid coloring the faces is to not show the faces:

```auto
actor.GetProperty().SetRepresentationToPoints()
actor.GetProperty().RenderPointsAsSpheresOn() # also recommended

```

To show the faces with a flat color, and use the scalars to color the points, you might need to use two mappers: one for the faces with `ScalarVisibilityOff()`, and one for the points with `ScalarVisibilityOn()` and with `SetRepresentationToPoints()` on the property.

---

<div class="post-metadata">

### Author: ![BotellaA](https://discourse.vtk.org/user_avatar/discourse.vtk.org/botellaa/32/1243_2.png) [@BotellaA](https://discourse.vtk.org/u/BotellaA)
#### Post date: [December 21, 2024, 6:42pm UTC](https://discourse.vtk.org/t/display-scalar-value-on-points/15054/6 "2024-12-21T18:42:58Z")

</div>

Thanks a lot a these insights.

You mention using two mappers linked to the same data. Are they also both linked to the same actor or each mapper should have its own actor?

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [December 21, 2024, 8:54pm UTC](https://discourse.vtk.org/t/display-scalar-value-on-points/15054/7 "2024-12-21T20:54:58Z")

</div>

Yes, each mapper needs its own actor and vice-versa.
