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
 Matrix System Design

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
tinkusch Posted - 08/14/2008 : 12:48:03 PM
Origin 7.5 German / XP

Hi folks,
I have defined a system design named Matrix1.oth as a reference for colored contour plots of matrices (cmap..). It works fine but only on one page, even when I delete and reload the matrices in that diagram on that page. I would like to use this design for other plots on other pages too. I expected that the system design is used automatically whenever a new plot of that type is generated or an existing plot is changed (e.g. new matrix values), but in my case it does not work on other pages. I always have to redo the settings once again by hand. (Especially I would like to get rid of the contour lines!!!)
Can someone please answer/comment on the following questions:
1) How can a system design or an other design from the design gallery be applied to a diagram or plot on a page with a labtalk (or C) script?
2) Why is a system design not automatically operative to new plots?
3) How are contour lines switched on/off in contour plots?

Thanks a lot for any help
bye
Stefan
4   L A T E S T    R E P L I E S    (Newest First)
Deanna Posted - 08/18/2008 : 03:59:21 AM
Hi Stepha,

As you can see in our Programming Help, DataPlot::SetColormap() can be used to set colormap levels scale to Logarithmic. You can use the following prototype:
PUBLIC  BOOL SetColormap(const vector<double>& vz, BOOL bLogScale=FALSE)

By setting bLogScale to true, you can use it to turn on the Log scale for the colormap levels.

I tried the following code on a color contour plot created from \Sample\Data\3D Matrix.DAT:


void Set_Log_Colormap()
{
	GraphPage gp = Project.Pages();
	GraphLayer glay = gp.Layers();
	DataPlot dp = glay.DataPlots(0);
	vector vZs = {540, 710.7, 925,3, 1231};
	BOOL bRet;
	
	bRet = dp.SetColormap(vZs, true);

}


This function was able to change the contour levels and set them to log.

What you have posted looks like our sample code, which does not set bLogScale to true. So it cannot be used to turn on the Log scale for the contour levels. If you are using your own Origin C function and the function fails to work, would you please post the function here so that we can have a look?

Yes, the color index in LabTalk layer.cmap.color properties starts from 0. It regards "black" as the "0th" color. It is mentioned in the LabTalk reference. Maybe it is not easy to find this information. We appologize for the inconvenience.

Deanna
OriginLab Technical Services
Deanna Posted - 08/18/2008 : 03:26:43 AM
Hi Stefan,

You don't have to say sorry. We are very happy to help!

For applying theme, please try the following code:

void Run_ApplyFormat()
{
	Page pg = Project.Pages();
	pg.ApplyFormat(GetAppPath(false)+"themes\\Matrix1.OTH");
}


We cannot use "%Y" in Origin C. It is a LabTalk variable. So I replaced it with "GetAppPath(false)".

I am reading other questions. I will post later if I can come up with solutions.

Deanna
OriginLab Technical Services
tinkusch Posted - 08/17/2008 : 07:26:41 AM
Hi Deanna,
thanks for your help. I am sorry for my longish answer and some additional questions. This is mainly due to the fact that for cmap control the descriptions in the help file are - at least to me - confusing and not complete. I am sorry but I can't get specific information from help how LabTalk Cmap options and C-functions are set and work together. I would apprechiate very much, if this part of the help file is revised completely.

I have found the following function to switch the CMAP contour lines on/off it the ORIGIN C Reference help file (Version O75G SR2, keyword: DataPlot::GetColormap
(really not easy to find ...)

BOOL HideLines(int nShow)
{
GraphPage gp("graph1");
if(!gp.IsValid() )
return FALSE;
// Get graph layer from collection in graph page
GraphLayer gl = gp.Layers();
if(!gl.IsValid() )
return FALSE;
// Get data plot from collection in graph layer
DataPlot dp = gl.DataPlots(0);
if( !dp.IsValid() )
return FALSE;
TreeNode tr;
dp.GetColormap(tr);
vector<int> vLShow;
vLShow = tr.Details.ShowLines.nVals;
vLShow = nShow;
tr.Details.Remove();
tr.Details.ShowLines.nVals =vLShow;
dp.SetColormap(tr);
return TRUE;
}

This function works fine.

However, the C-function ApplyFormat() to apply a theme to a plot does not work im my case. Here's the code I tried:

void Run_ApplyFormat()
{
Page pg = Project.Pages();
pg.ApplyFormat(%Ythemes\Matrix.OTH);
}

Matrix.oth is a self-made theme for Cmap-plots. I also tried it with other ORIGIN themes, but it did not work either, so I am quite sure the mistake is not in my *.oth-file.
Question: Does this function only apply to the active plot? How can I set a pointer to a given page, layer or plot?

Next problem I have is how to switch on/off the logarithmic scale in Cmap contour plots. This should be possible with the
following C-Function:

void test_Set_Colormap(string MYPLOT, int nCount = 10)
{
GraphPage gp(str);
GraphLayer glay = gp.Layers();
DataPlot dp = glay.DataPlots(0);
vector vZs = {1,5.5,10};
BOOL bRet;
BOOL bLogScale=TRUE;
if(nCount)
{
Tree tr;
tr.ColorMap.Count.nVal = nCount;
bRet = dp.SetColormap(tr);
}
else
{
bRet = dp.SetColormap(vZs, false);
}
}

where BOOL bLogScale=TRUE sets the logarithmic scale and FALSE sets a linear scale to a CMAP contour plot on page MYGRAPH.

In my case this function simply alters the number of colormap levels, but does not change from log to lin scale. DO i have to set the layer.cmap.zMin value > 0 before switching to log-scale?

Next (minor) problem: The color index set by LabTalk layer.cmap.color properties differs by -1 from the ORIGIN Formate Color Palette: e.g. black has the index 0 instead of 1 for the cmap properties.

Again sorry for this longish contribution and thanks for any help.
Stefan









Deanna Posted - 08/15/2008 : 02:33:43 AM
Hi Stefan,

Formats and styles saved in a system theme should be applied when a new graph is created. I tried to create a contour plot and then do some customization to the color map of the graph. Then I save all settings as a theme and set it as the system theme. Next time I create a contour plot (either with LabTalk or from GUI), the system theme is applied. I am not sure what caused the problem in your case, would you please send us the file matrix1.oth so that we can do some tests? It will be great if you can also send us a sample contour graph, on which you wish to apply the theme. Please send us the file with this web page:
http://www.originlab.com/www/company/qform.aspx?s=1&

To apply a theme to a plot with Origin C, you can use the ApplyFormat() member function of the Origin Object class. You can see details and examples in this page in our programming help (Help: Programming):
Origin C Programming Reference > Classes > Internal Origin Objects > Origin Object > ApplyFormat

To switch the contour lines on/off with Origin C, you can refer to another page in Origin programming help:
Programming Guide > Programming in Origin C > Accessing Plot Properties with Trees
Sorry, currently I can't find any method to do it in LabTalk.


Deanna
OriginLab Technical Services

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