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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 How can I print out the colormap used??
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

DanielHenry

2 Posts

Posted - 06/22/2020 :  01:53:06 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

lkb0221

China
497 Posts

Posted - 06/30/2020 :  09:17:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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]))

Edited by - lkb0221 on 06/30/2020 09:18:05 AM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000