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
 Forum for Origin C
 How to add the comments in the graph?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

liujibao

China
Posts

Posted - 02/15/2004 :  09:09:12 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Before exporting to BMP file, I want to add some comments in the curve graph, how to realize it in origin c? and can I modify its position?

Thanks!

Mike Buess

USA
3037 Posts

Posted - 02/15/2004 :  10:33:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This adds a label with the text sText to the active layer at the coordinates dX and dY....
void AddLabel(string sText, double dX, double dY)
{
GraphLayer gl = Project.ActiveLayer();
string sCmd;
sCmd.Format("label -a %f %f %s",dX,dY,sText);
gl.LT_execute(sCmd);
}


Mike Buess
Origin WebRing Member
Go to Top of Page

liujibao

China
Posts

Posted - 02/15/2004 :  11:32:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks!

Edited by - liujibao on 02/15/2004 11:56:57 PM
Go to Top of Page

Dominik Paulkowski

Germany
Posts

Posted - 05/08/2008 :  07:15:28 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello everybody!

AddLabel is a very useful function to add label text to a graph. I use it very often. But there are at least two limitations at the ".Format" command. I recommend a piecewise merging like that:

void AddLabel(GraphLayer gl, string sText, double dX, double dY)
{

//GraphLayer gl = Project.ActiveLayer();

string sCmd;

//sCmd.Format("label -a %f %f %s",dX,dY,sText);
// .Format shorten the dX and dY in the string to six decimal digits
// .Format cannot handle equal sign "=" in string -> cause error at execution (without error message)
// Better use adding piecewise:
sCmd = "label -a " + dX + " " + dY + " " + sText;

gl.LT_execute(sCmd);


} // End of AddLabel

Thank you again for the nice funtion, Mike. :-)

-------------------
:-Dipl.-Phys. Dominik Paulkowski
Fraunhofer Institute for Surface Engineering and Thin Films (IST)
Braunschweig
Germany
Go to Top of Page

greg

USA
1380 Posts

Posted - 05/09/2008 :  12:07:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
With a small modification, namely
sCmd.Format("label -s -sa -a %f %f %s",dX,dY,sText);
you can use escape sequences to interpret some of those problematic characters (-sa), and pass along substituted strings and variables (-s) as in:
AddLabel("pi \x3D $(pi) \x5BProject : %G\x5D", 5, 1);
which yields the label
pi = 3.14159 [Project : UNTITLED]


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