The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 How can I print out the colormap used??

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
DanielHenry Posted - 06/22/2020 : 01:53:06 AM
Hi,

I want to print out the colormap used in a surface plot, so I can reuse exactly the same in other plotting programs.

How can I do this, aside from manually copying over every range and color value from the Plot details->colormap dialog (where I cannot actually even access the color value)?

Or is there a way to make sense of the exported XML .oth colormap?

It doesn't have to be in LabTalk, but that seems to have worked better than the python module so far.
I am happy with any solution for this.

Infos:
------
Origin Ver. and Service Release (Select Help-->About Origin):
Origin 2019b (64-bit)
9.6.5.169 (Academic)
Operating System: Windows 10
1   L A T E S T    R E P L I E S    (Newest First)
lkb0221 Posted - 06/30/2020 : 09:17:43 AM
For a pure LT solution, you can use the layer.cmap object to read out every single level value and color, build a wks, and export it.
https://www.originlab.com/doc/LabTalk/ref/Layer-CMap-obj

For Python, you can try something like this (since you're using 9.6):
import PyOrigin

# Assume there is a contour graph been activated
ColorLevels = int(PyOrigin.LT_get_var('layer.cmap.numColors'))
ListR, ListG, ListB = ([None]*ColorLevels for i in range(3))

for ColorInd in range(ColorLevels):
	Ocolor = PyOrigin.LT_get_var("layer.cmap.color{0}".format(ColorInd))
	PyOrigin.LT_execute("int var = ocolor2rgb({0})".format(Ocolor))
	RGB = PyOrigin.LT_get_var('var')
	ListR[ColorInd], ListG[ColorInd], ListB[ColorInd] = [float((int(RGB) >> (8*i)) & 255) / 255 for i in range(3)]

with open("ColorPaletteSample.pal", "w") as f:
	for ColorInd in range(ColorLevels):
		f.write("{0},{1},{2}\n".format(ListR[ColorInd], ListG[ColorInd], ListB[ColorInd]))

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000