# Toggle color legend visibility code

**URL:** https://discourse.paraview.org/t/toggle-color-legend-visibility-code/3523
**Category:** ParaView Support
**Created:** [February 6, 2020, 6:14pm UTC](https://discourse.paraview.org/t/toggle-color-legend-visibility-code/3523 "2020-02-06T18:14:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Shubham\_Belgaonkar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/shubham_belgaonkar/32/2081_2.png) [@Shubham\_Belgaonkar](https://discourse.paraview.org/u/Shubham_Belgaonkar)
#### Post date: [February 6, 2020, 6:14pm UTC](https://discourse.paraview.org/t/toggle-color-legend-visibility-code/3523/1 "2020-02-06T18:14:01Z")

</div>

I have the code to visualize some netcdf files.  
Can someone tell the code on how to change the color legend.

---

<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: [February 7, 2020, 2:36am UTC](https://discourse.paraview.org/t/toggle-color-legend-visibility-code/3523/2 "2020-02-07T02:36:44Z")

</div>

I suppose that you are using python and not the GUI ?

What do you mean by “change the color legend” ? Please be more precise.

---

<div class="post-metadata">

### Author: ![Shubham\_Belgaonkar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/shubham_belgaonkar/32/2081_2.png) [@Shubham\_Belgaonkar](https://discourse.paraview.org/u/Shubham_Belgaonkar)
#### Post date: [February 7, 2020, 3:05am UTC](https://discourse.paraview.org/t/toggle-color-legend-visibility-code/3523/3 "2020-02-07T03:05:53Z")

</div>

Yes I am using python. I want to use gray scale color bar. I wanted to know the syntax for it. If not the color bar, how can i change the color of the object ?

---

<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: [February 7, 2020, 3:13am UTC](https://discourse.paraview.org/t/toggle-color-legend-visibility-code/3523/4 "2020-02-07T03:13:10Z")

</div>

```
lut = GetColorTransferFunction("YourVariable")
lut.ApplyPreset('X Ray', True)

```

Use tools -\> Start trace in the GUI when you do not know how to do something in python.

---

<div class="post-metadata">

### Author: ![Shubham\_Belgaonkar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/shubham_belgaonkar/32/2081_2.png) [@Shubham\_Belgaonkar](https://discourse.paraview.org/u/Shubham_Belgaonkar)
#### Post date: [February 7, 2020, 3:14am UTC](https://discourse.paraview.org/t/toggle-color-legend-visibility-code/3523/5 "2020-02-07T03:14:11Z")

</div>

okay thankyou.
