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
 Forum for Origin C
 Colormap is not refreshed.

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
winflowers Posted - 07/01/2009 : 08:54:54 AM
Origin Ver. and Service Release (Select Help-->About Origin): Origin 7.5 SR6 v7.5885(B885)
Operating System: windows XP

I have a problem to draw a contour plot with Origin C. The code is like following:

void ScaleColors ()
{
	Matrix mat("Matrix1");
	double dMax=mat.GetMax();
	
	Page pg("MatPage");
	if (!pg)
		return;
	GraphLayer gly = pg.Layers(ii);
//	set_active_layer(gly);
	DataPlot dp = gly.DataPlots(0);
	Tree tr;
	if( !dp.GetColormap(tr) ) 
		return;
	tr.Min.dVal = 0;
	tr.Max.dVal = dMax*1.1;
	if( !dp.SetColormap(tr) )
		printf("Failed to set color map\n");
}


The Min and Max value can be set by these codes. However, the plot did not change accordingly. I could see the new Min and Max values in Plot details->Color map->Set Levels. If I click OK and Apply without doing anything else, the colormap is changed according to the Min and Max values I have set with the above code.

I searched the forum and found similar topic, but no answer.
http://www.originlab.com/forum/topic.asp?TOPIC_ID=5703

What I need is simple: the color of contour plot can be changed according to given Min and Max values. The color is from Blue(small) to Red(big). What should I do to refresh the colormap?

Thanks in advance for your kind help!
12   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 07/09/2009 : 08:21:22 AM
I am not sure but it seems best to set z levels with vector.
One thing different from my own simple test is that your colormap has different number of levels(500) then the default(8) and I was using default, maybe that made the difference.
winflowers Posted - 07/09/2009 : 06:59:30 AM
Thank CP! The code works!
I am wondering what is going on with my OPJ file because you mentioned in your earlier post that the code worked in your environment. And you said that "you must set color map using vector first before you can use the tree". Is it true for every case or just for my OPJ? What is special in my file?
Thanks everyone again! I am very happy that I can always get answers here.
cpyang Posted - 07/09/2009 : 05:34:37 AM
Sorry I didnt get to this earlier.

I looked and found that you must set color map using vector first before you can use the tree. In your case, if you are only changing the z level and not change anything else, you can simply call it with the vector version, like this

void sc()
{
	Matrix mat("QEFLeft");
	double dMax=mat.GetMax();
	double z1 = 0, z2=dMax*1.1;
	
	Page pg("AQEF");
	if (!pg)
		return;
	for(int ii = 0; ii < pg.Layers.Count(); ii++)
	{
		GraphLayer gly = pg.Layers(ii);
		DataPlot dp = gly.DataPlots(0);
		vector vz1;
		BOOL bLogScale = FALSE;
		dp.GetColormap(vz1, bLogScale);
		vector vz2;
		int nLevels = vz1.GetSize();
		
		vz2.Data(z1, z2, (z2-z1)/(nLevels-1));
		
		if( !dp.SetColormap(vz2, bLogScale) )
			printf("Failed to set color map\n");
	}
}


winflowers Posted - 07/09/2009 : 02:56:44 AM
Is there any solution? I have not got any response yet.
winflowers Posted - 07/03/2009 : 10:07:55 AM
quote:
Originally posted by cpyang

It seems that your original code should work just fine. I suggested Z1=Z1 before I tried your code. Now I tried and I see no probelm in Origin 7.5 SR6.

Maybe you can email me the OPJ file, cp@originlab.com.





I have sent you the OPJ file.
winflowers Posted - 07/03/2009 : 08:44:37 AM
The Rescale Mode was "Normal". I did some experiments according to your suggestion.

1. Rescale Mode = "Normal". Running the code, the colormap does not show correctly;
2. Rescale Mode = "Manual". Running the code, the colormap does not show correctly;
3. Rescale Mode = "Normal". Running the code, the colormap does not show correctly. Then switching Rescale Mode to "Manual", the colormap shows correctly;
4. Rescale Mode = "Manual". Running the code, the colormap did not show correctly. Then switching Rescale Mode to "Manual", the colormap shows correctly;
5. Rescale Mode = "Normal". Running the code, the colormap does not show correctly. Then selecting the Rescale Mode list box, but still selecting the "Normal" mode, the colormap shows correctly;

It seems that I need do something to let Origin believe that something has been changed. Then it updates the plot correctly. But actually I need not do any changes.
cpyang Posted - 07/03/2009 : 08:26:59 AM
It seems that your original code should work just fine. I suggested Z1=Z1 before I tried your code. Now I tried and I see no probelm in Origin 7.5 SR6.

Maybe you can email me the OPJ file, cp@originlab.com.

Iris_Bai Posted - 07/03/2009 : 06:13:45 AM
Change Rescale Mode and run your function again.
Double click on graph to open Plot Details dialog, in Color Map/ Contours tab there is a list box named Resacle Mode.

Iris
winflowers Posted - 07/03/2009 : 03:58:49 AM
I have tried it, but it doesn't help as well.

Once I changed any values in the "Set Levels" dialog manually and click "OK". Then my code runs correctly. Are there any clues?

I also compared the colormap tree before and after clicking the "OK" button in "Set Levels" dialog, and they are exactly same. By the way, the contour plot was created based on a customized template. Could this make the trouble? I really run out of ideas.
cpyang Posted - 07/02/2009 : 6:06:20 PM
try

pg.LT_execute("Z1=Z1");

This may force internal update.

CP
winflowers Posted - 07/02/2009 : 07:06:43 AM
Thanks for your comments. Unfortunately, it does not help.
Are there anything I forgot in my codes?

By the way, I can see the colormap changes after running the code, but not as I desired. Only when I click "OK" in "Set Levels" of "Plot Details", the colormap shows correctly. More comments?
Iris_Bai Posted - 07/02/2009 : 02:26:20 AM
Hi,

May be need to refresh, please try the following codes after SetColormap.


bool bRedraw = true;
pg.Refresh(bRedraw);


Iris

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