# Some questions about categorical colors

**URL:** https://discourse.paraview.org/t/some-questions-about-categorical-colors/12860
**Category:** ParaView Support
**Created:** [September 14, 2023, 3:58am UTC](https://discourse.paraview.org/t/some-questions-about-categorical-colors/12860 "2023-09-14T03:58:41Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![fashing](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fashing/32/12357_2.png) [@fashing](https://discourse.paraview.org/u/fashing)
#### Post date: [September 14, 2023, 3:58am UTC](https://discourse.paraview.org/t/some-questions-about-categorical-colors/12860/1 "2023-09-14T03:58:42Z")

</div>

Hi Paraview,  
I am trying this `categorical colors` function in Paraview and I have some questions.  
Here is the [testcase.vdb](https://discourse.paraview.org/uploads/short-url/msWjzvfeqbdUiHFSggnBUz4djnZ.vdb) I used.

1. Does it worked with `volume` representation?  
After I check `Interpret Values As Categories`, I got something as same as before.  

2. From the [document](https://docs.paraview.org/en/latest/ReferenceManual/colorMapping.html#categorical-colors), I saw this function is supported in pvpython. Since the example in the document only set rgb value, I wonder if we can also manipulate the `opacity mapping` in python.

3. I noticed there are several applications (e.g. paraview-web, paraview-visualizer and paraview-lite) for using paraview. Is this function also implemented there? I saw for paraview-visualizer is not, how about the other two application?

Thank you!

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [September 14, 2023, 7:16am UTC](https://discourse.paraview.org/t/some-questions-about-categorical-colors/12860/2 "2023-09-14T07:16:29Z")

</div>

Volume does not support interpret values as categories I’m afraid

[https://gitlab.kitware.com/paraview/paraview/-/issues/22299](https://gitlab.kitware.com/paraview/paraview/-/issues/22299)

> [@"Interpret Values As Categories" does not work with TIFF Series Reader](https://discourse.paraview.org/t/interpret-values-as-categories-does-not-work-with-tiff-series-reader/11313):
>
> Hi, I have a 3d array saved in a tiff file whose contents I want to look at in Paraview. The array contains categorical data, so each pixel is either 0, 1, or 2. I import the tiff file in Paraview with the TIFF Series Reader and it is correctly displayed when switching Volume Representation. However, when I click Interpret Values As Categories in the Color Map Editor the colors of the different regions do not change. I am using Paraview 5.10.1 as in this post (["Interpret values as categories" n…](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155)

---

<div class="post-metadata">

### Author: ![fashing](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fashing/32/12357_2.png) [@fashing](https://discourse.paraview.org/u/fashing)
#### Post date: [September 15, 2023, 7:34am UTC](https://discourse.paraview.org/t/some-questions-about-categorical-colors/12860/3 "2023-09-15T07:34:00Z")

</div>

Hi @mwestphal,  
I am testing categorical colors in python through `trame`.  
And I ran into this `error: Uncaught TypeError: t.mapDataIndexed is not a function`, here is my code:

```auto
from paraview import simple

view = simple.CreateRenderView()
source = simple.OpenVDBReader(FileName=r'testcase.vdb')
arrayName = source.PointData.GetArray(0).Name

displayProps = simple.Show(source, view)
displayProps.Representation = 'Surface'
simple.ColorBy(displayProps, ('POINTS', arrayName), True)
# everything works until here, showing the default color set "Cool to Warm"

categoricalColorMap = simple.GetColorTransferFunction(arrayName, displayProps)
categoricalColorMap.InterpretValuesAsCategories = 1
# error happens when I set this

```

And also, when I ran `displayProps.SetScalarBarVisibility(view, True)`, a warning came out `[paraview] Failed to determine the LookupTable being used` and the scalar bar was not shown.

I am affraid `trame` has issue to choose look up table, or did I miss something?  
Thank you for your time!

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [September 15, 2023, 8:03am UTC](https://discourse.paraview.org/t/some-questions-about-categorical-colors/12860/4 "2023-09-15T08:03:01Z")

</div>

@jourdain

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [September 15, 2023, 3:18pm UTC](https://discourse.paraview.org/t/some-questions-about-categorical-colors/12860/5 "2023-09-15T15:18:53Z")

</div>

That issue has nothing to do with trame. Just make sure your script is valid for ParaView.  
You can use the “python trace” to get the code from your GUI interaction.

---

<div class="post-metadata">

### Author: ![fashing](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fashing/32/12357_2.png) [@fashing](https://discourse.paraview.org/u/fashing)
#### Post date: [September 18, 2023, 3:10am UTC](https://discourse.paraview.org/t/some-questions-about-categorical-colors/12860/6 "2023-09-18T03:10:12Z")

</div>

Hi @jourdain,  
Thank you for the useful suggestion!  
I’ll check my script.

---

<div class="post-metadata">

### Author: ![fashing](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fashing/32/12357_2.png) [@fashing](https://discourse.paraview.org/u/fashing)
#### Post date: [September 18, 2023, 6:31am UTC](https://discourse.paraview.org/t/some-questions-about-categorical-colors/12860/7 "2023-09-18T06:31:10Z")

</div>

Hi @jourdain,  
I think my script is fine, it works with the `Run Script` under python shell in Paraview GUI.  
And the same error still exist when I copy & paste the whole code directly from the output of python trace.

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [September 18, 2023, 3:24pm UTC](https://discourse.paraview.org/t/some-questions-about-categorical-colors/12860/8 "2023-09-18T15:24:45Z")

</div>

So are you saying that all is good since you get the same behavior between ParaView and trame?

---

<div class="post-metadata">

### Author: ![fashing](https://discourse.paraview.org/user_avatar/discourse.paraview.org/fashing/32/12357_2.png) [@fashing](https://discourse.paraview.org/u/fashing)
#### Post date: [September 19, 2023, 3:08am UTC](https://discourse.paraview.org/t/some-questions-about-categorical-colors/12860/9 "2023-09-19T03:08:05Z")

</div>

I think so. Here is the file [cate.py](https://discourse.paraview.org/uploads/short-url/yQSQHFUrsE21OPSRdnu4MjWJWuj.py) I tested with previous `vdb` file.  
The paraview code part works in paraview python shell (update: also works by using `pvpython cate.py` by a little modification), but it fails when I launch it through trame.

And here is the file I paste all output from python trace and still failed rendering through trame.  
[detail.py](https://discourse.paraview.org/uploads/short-url/8A3n6kRULuFbDNfpZ7IIhAk6IFy.py)

Hope the information is clear, thank you for your time.
