Applying color to volume through script?

I have a volume and want to apply color to it as we do in the segment editor module.How can I apply color to it from code?

You can find code examples to all commonly needed operations in the script repository - see how to change the lookup table for a volume here.

A post was split to a new topic: How to change Segment Editor Paint effect options from Python script