# Adjust volume rendering transfer function in Python

**URL:** <https://discourse.slicer.org/t/adjust-volume-rendering-transfer-function-in-python/12069>\
**Category:** Development\
**Tags:** volume-rendering\
**Created:** [June 17, 2020, 12:07pm UTC](https://discourse.slicer.org/t/adjust-volume-rendering-transfer-function-in-python/12069 "2020-06-17T12:07:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [June 17, 2020, 12:27pm UTC](https://discourse.slicer.org/t/adjust-volume-rendering-transfer-function-in-python/12069/2 "2020-06-17T12:27:21Z")

</div>

This function works for me, please see it as example:

> <https://gist.github.com/cpinter/8a1f71c7eb3ef0ebcaa6c1be6e1c9d4a>

For the record, this is the topic referred to above:

> [@How to set volume rendering preset using Python](https://discourse.slicer.org/t/how-to-set-volume-rendering-preset-using-python/3063):
>
> Hi developers, Using a Python script I am trying to load a volume, set the slice views and also a volume rendering preset. While loading and setting the slice views works out well, the volume rendering always shows up with the default settings and not the targeted preset. Could someone please give me a hint of what’s missing? Is there a way to adjust the preset parameter “shift” in advance? Since I am new to Slicer development I would also be happy about any hint of how to improve the code (i…

---

_[View the full topic](https://discourse.slicer.org/t/adjust-volume-rendering-transfer-function-in-python/12069)._
