# Learning the difference between SetScalars vs SetVectors

**URL:** https://discourse.vtk.org/t/learning-the-difference-between-setscalars-vs-setvectors/6669
**Category:** Support
**Created:** [September 22, 2021, 4:07am UTC](https://discourse.vtk.org/t/learning-the-difference-between-setscalars-vs-setvectors/6669 "2021-09-22T04:07:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nicholas\_Yue](https://discourse.vtk.org/user_avatar/discourse.vtk.org/nicholas_yue/32/3751_2.png) [@Nicholas\_Yue](https://discourse.vtk.org/u/Nicholas_Yue)
#### Post date: [September 22, 2021, 4:07am UTC](https://discourse.vtk.org/t/learning-the-difference-between-setscalars-vs-setvectors/6669/1 "2021-09-22T04:07:43Z")

</div>

I am trying to add point data like density (scalar) and velocity (vector) to point data

I am trying to understand when to use which because the following example kind of threw me off.

> <https://github.com/lorensen/VTKExamples/blob/a195d67ddd662c821431e07c5a14d1804af4153e/src/Cxx/Visualization/ColorGlyphs.cxx#L31>

A color to me is like a vector of 3 component but yet the SetScalars method is used.

Where can I read up more about the difference between SetScalars and SetVectors usage and the design behind it?

Thank you

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [September 22, 2021, 1:25pm UTC](https://discourse.vtk.org/t/learning-the-difference-between-setscalars-vs-setvectors/6669/2 "2021-09-22T13:25:47Z")

</div>

Indeed, scalars have one component most commonly. That example uses “scalars” with 3 components because it uses direct coloring.  
This can be used, for instance, for a model that shows different parts with different colors. So instead of using an integer part number and then color mapping that, you store the color directly.

This is the new site for VTK Examples.

[https://kitware.github.io/vtk-examples/site/Cxx/Visualization/ColorGlyphs/](https://kitware.github.io/vtk-examples/site/Cxx/Visualization/ColorGlyphs/)

---

<div class="post-metadata">

### Author: ![Nicholas\_Yue](https://discourse.vtk.org/user_avatar/discourse.vtk.org/nicholas_yue/32/3751_2.png) [@Nicholas\_Yue](https://discourse.vtk.org/u/Nicholas_Yue)
#### Post date: [September 22, 2021, 3:42pm UTC](https://discourse.vtk.org/t/learning-the-difference-between-setscalars-vs-setvectors/6669/3 "2021-09-22T15:42:42Z")

</div>

Thank you @danlipsa , in a separate thread about multiple pointsdata array, I was made aware of [this](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/5292), I am now using AddArray() as it gives a consistent interface for my usecase.

Cheers
