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
 show/hide numbers on graph plot

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
asenv Posted - 06/24/2010 : 11:15:30 AM
Origin Ver. and Service Release (Select Help-->About Origin): 8.1G SR1
Operating System: win 2000 pro

I want control which numbers of the of the cmap object that apper on the plot. Lets say as a simple example I want to hide them. To reproduce my problem do the following:

1 open origin
2 create matrix
3 set matrix values to rnd() (in menu matrix->set values->rnd())
4 open script window (menu->window->scrip window)
5 execute "worksheet -p 226"
//you get the plot with many number on it
6 open code builder nad create new c file
7 paste the following code
#include <Origin.h>

void hidenumberstest001(void){

GraphLayer gl = Project.ActiveLayer();
DataPlot dp = gl.DataPlots(0);

Tree tr;
tr = dp.GetFormat(FPB_ALL, FOB_ALL, true, true);
 
// Show all labels
vector<int> vnLabels;
vnLabels = tr.Root.ColorMap.Details.Labels.nVals;
vnLabels = 0;// 0 to hide, 1 to show
tr.Root.ColorMap.Details.Labels.nVals = vnLabels;
dp.ApplyFormat(tr, true, true);
}


8 compile the code (shift + F8)
9 in the script window execute "hidenumberstest001"
//nothing happens although it should hide the numbers

After *long* time debugging I noticed that it actually works if I uncheck the lable option "Nur auf Hauptebenen zeigen". See screenshots:





So how do I unset this option programatically?
5   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 07/25/2010 : 11:16:55 PM
Hi Asen,

I can not get the errors you mentioned. Could you please send us all the code and the project file (*.opj) via this page? It will be better to provide more details about the steps.

Remember to refer to this post when you send files to us.

To get the format tree to see the details of tree structure, you can set a break point on the line which is calling GetFormat. Or you can use the out_tree function to output the tree structure. For example:

void hidenumberstest001()
{
	GraphLayer gl = Project.ActiveLayer();
	DataPlot dp = gl.DataPlots(0);
	Tree tr;
	tr = dp.GetFormat(FPB_ALL, FOB_ALL, true, true);  // can set a break point on this line
	out_tree(tr);  // output tree structure
}



Penn
asenv Posted - 07/22/2010 : 07:41:13 AM
Hi Penn,
thanks for your solution. It works now and I can work forward. I have a question though:
When I execute "hidenumberstest001" in the script window I get this error:
hidenumberstest001;


Set theme error (356.472)
Set theme error (356.473)
Set theme error (356.368)
Set theme error (356.1125)
Set theme error (356.1126)
Set theme error (356.1127)
Set theme error (356.1128)


It happens when I integrate all that code with labview/labtalk too. Do you have any idea why I get this response.

P.S. If I may ask, where do you get the info about this line of code?

tr.Root.ColorMap.MajorLabels.nVal = 0;  // uncheck Nur auf Hauptebenen zeigen


I searched in google and locally in the originlab.com page and in the latest OriginC.chm file and I can not find any info about "MajorLabels".

Best Regards,
Asen
Penn Posted - 06/29/2010 : 04:03:16 AM
Hi Asen,

To uncheck the check-box "Nur auf Hauptebenen zeigen" programatically, please try the following code.

void hidenumberstest001()
{
	GraphLayer gl = Project.ActiveLayer();
	DataPlot dp = gl.DataPlots(0);
	Tree tr;
	tr = dp.GetFormat(FPB_ALL, FOB_ALL, true, true);
	
	vector<int> vnLabels;
	vnLabels = tr.Root.ColorMap.Details.Labels.nVals;
	vnLabels = 0;
	tr.Root.ColorMap.MajorLabels.nVal = 0;  // uncheck Nur auf Hauptebenen zeigen
	tr.Root.ColorMap.Details.Labels.nVals = vnLabels;
	dp.ApplyFormat(tr, true, true);
}

In the example you tried to run, the minimum version of Origin is 8.1 SR2. You are using Origin 8.1 SR1, right? So, you can update from this page and then try the example again.

Please note that the function set_label_format in the example is defined for setting the label format. It is called by function plot_xyz_contour_ex2, but can not run in the command window(with prompt >>).

Penn
asenv Posted - 06/25/2010 : 05:17:14 AM
Hi Shirley,
i have trouble with the funktion set_label_format when I try to run the example you send me. I copy pasted this code
void plot_xyz_contour_ex2()
{
   Worksheet wks = Project.ActiveLayer();  // get active worksheet
   if( !wks )
       return;
 
    // construct the XYZ data range
    DataRange dr;
    dr.Add(wks, 0, "X");
    dr.Add(wks, 1, "Y");
    dr.Add(wks, 2, "Z");
 
    GraphPage gp;
    gp.Create("TriContour");  // create contour graph
    if( gp )
    {
        GraphLayer gl = gp.Layers();
        if( gl )
        {
            int nPlot = gl.AddPlot(dr, IDM_PLOT_TRI_CONTOUR);  // add contour plot to layer
            DataPlot dp = gl.DataPlots(nPlot);  // get the added plot
            gl.Rescale();     // rescale layer
 
           // set_contour_lines(dp);  
           set_label_format(dp);  // set label format
 
            gp.Refresh();  // refresh graph
        }
    }
}
 
void set_label_format(DataPlot& dp)
{
	if(!dp)
		return;
 
	vector vLevels;
	BOOL bLogScale;
	if(!dp.GetColormap(vLevels, bLogScale))  // get colormap of plot
		return;
 
	int nNumLabels = vLevels.GetSize() - 1;  // number of labels
	vector<int> vnLabelShow(nNumLabels);
	vnLabelShow = 1;  // show labels
 
	Tree trFormat;
	trFormat.Root.ColorMap.Details.Labels.nVals = vnLabelShow;  // show labels
	trFormat.Root.Labels.Color.nVal = SYSCOLOR_MAGENTA;  // color=magenta
	trFormat.Root.Labels.Size.dVal = 30;  // size=30
	trFormat.Root.Labels.Bold.nVal = true; 
	trFormat.Root.Labels.Italic.nVal = true;
 
	if(0 == dp.UpdateThemeIDs(trFormat.Root))
		if(!dp.ApplyFormat(trFormat, true, true))   // apply format
			out_str("Failed to apply format!");
}


to a new *.c file created from code builder. Then compiled the file (there were no errors). Then imported <Origin Installation Directory>\Samples\Matrix Conversion and Gridding\XYZ Random Gaussian.dat and tried to run "plot_xyz_contour_ex2" and "set_label_format" function. "plot_xyz_contour_ex2" runs and creates a contour plot, the function can also be ssen in the "list f" list. "set_label_format" is not in the list and can not be executed even from the c script terminal or smth with this prompt ">>". So why does that happen? How do I access this function to execute it and test it?

Best Regards,
Asen

P.S. I also had the question: How to uncheck this box "Nur auf Hauptebenen zeigen" programatically?
Shirley_GZ Posted - 06/25/2010 : 03:43:53 AM
Hi Asenv,

To hide the labels on the contour plot, please refer to this OC example, http://www.originlab.com/www/helponline/Origin/en/programming/mergedProjects/OriginC/OriginC/Plot_XYZ_Contour_from_worksheet_and_custom_lines.html#Plot_XYZ_Contour_from_Worksheet_and_Custom_Labels.

Hope this is helpful.

Thanks,
Shirley

Originlab Technical Service Team

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