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
 Multi-file importing and ploting
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

kanderlee

Taiwan
Posts

Posted - 09/20/2007 :  05:08:30 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (7.5 SR4):
Operating System: Win XP

http://www.originlab.com/ftp/programming/SimpleImportAndPlot.c

This example can work properly in my computer, but I hope someomecan help to modify it into suitable functions which I need.

I need to import multi-files at the same time. Then each file can create its worksheet and graphplot in the same project file.

If I select 5 data files in the dialog box, I will get five indepent worksheets and graphplot in the project file. The lable of the worksheet and the graphplot would be easy to recognize that they are from the same datafile.

Thank for your helping.

Mike Buess

USA
3037 Posts

Posted - 09/20/2007 :  5:50:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You'll find in these forums many ways to import and process multiple ASCII files but rather than searching the forum I just modified the function you already found. (You can just copy&paste this function to SimpleImportandPlot.c.) Red lines are those I commented out. Blue lines are those I added.

void multiple_import_and_plot()
{
// Bring up file dialog for user to select the file.
// Replace *.dat with your desired extension as needed.
StringArray saFiles;
int iNumFiles = GetMultiOpenBox(saFiles, "*.dat");

//string strFile = GetOpenBox("*.dat");
//if( strFile.IsEmpty() )

if( iNumFiles==0 )
{
out_str("No file was selected!");
return;
}
for(int i=0;i<iNumFiles;i++)
{

// Create a new worksheet
Worksheet wks;
// If you wish to use a custom worksheet template, then specify the name of
// your template in place of Origin.OTW
wks.Create("Origin.OTW");
string strFile = saFiles[i];
// Import the file into the worksheet using the current ASCIMP
// (Import ASCII Options) stored in the worksheet.
// You can edit the ASCIMP options from the GUI and save it back to
// the worksheet and then save the worksheet as a custom template.
// You can then create a new instance of your custom template and use it
// to import the data next time.
BOOL bRet = wks.ImportASCII(strFile);
if( !bRet )
{
out_str("Failed to import file!");
// Destroy newly created worksheet
wks.Destroy();
return;
}
wks.GetPage().Label = strFile; // set window label
wks.LT_execute("page.title=3"); // show label

// Create a default graph and plot all Y columns in the first layer
// as a grouped plot.
GraphPage gpg;
// If you wish to use a custom graph template, then specify the name
// of your template in place of Origin.OTP
gpg.Create("Origin.OTP");
gpg.Label = strFile;
gpg.LT_execute("page.title=3");

// Point to the first layer in the graph
// If you use a custom template that has multiple layers, you can
// then declare separate layer objects for each layer and move
// data plots into various layers as desired
GraphLayer gly = gpg.Layers(0);
// Loop over all columns and add to layer if Y column
foreach(Column col in wks.Columns)
{
if(OKDATAOBJ_DESIGNATION_Y == col.GetType())
{
// Create a curve object using this column
Curve crv(wks, col.GetIndex());
// Add as a line plot
gly.AddPlot(crv, IDM_PLOT_LINE);
}
}
// Group all the plots and rescale
gly.GroupPlots(0);
gly.Rescale();
}
}


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/20/2007 5:53:41 PM
Go to Top of Page

kanderlee

Taiwan
Posts

Posted - 09/20/2007 :  9:52:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you a lot, Mike. You really give me a "big" help, and I'm aslo impressed your quick response.

May I ask you an anther question? I only want to use the file names I imported as the Worksheet and Graphplot names instead of file path. How can I do?

Thank you again.

Kander

Edited by - kanderlee on 09/20/2007 9:53:36 PM

Edited by - kanderlee on 09/20/2007 10:45:52 PM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/21/2007 :  03:32:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
I only want to use the file names I imported as the Worksheet and Graphplot names instead of file path.
string strLabel = GetFileName(strFile); // strip path
wks.GetPage().Label = strLabel; // set worksheet label
// ...
gpg.Label = strFile; // set graph label

Mike Buess
Origin WebRing Member
Go to Top of Page

kanderlee

Taiwan
Posts

Posted - 09/21/2007 :  04:57:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It works perfect! Thank you a million...

Kander
Go to Top of Page

kanderlee

Taiwan
Posts

Posted - 09/26/2007 :  01:36:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
foreach(Column col in wks.Columns)
{
if(OKDATAOBJ_DESIGNATION_Y == col.GetType())
{
// Create a curve object using this column
Curve crv(wks, col.GetIndex());
// Add as a line plot
gly.AddPlot(crv, IDM_PLOT_LINE);
}

Hi, Mike:

Sorry to disturb you again.

For that part of the code I pasted above, if I plot a graph from a multi-column worksheet, how to show all line symbles on the plot? (The program just show the line symbol of the first y column in the worksheet.)

Thank you.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/26/2007 :  03:40:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Not sure what you mean. Your code plots all Y columns when I use it.

Mike Buess
Origin WebRing Member
Go to Top of Page

kanderlee

Taiwan
Posts

Posted - 09/26/2007 :  04:17:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry about I didn't say clearly or in the wrong way.

I want to show all line styles and symbols of the curves on the plot.

For instance, there is a worksheet with 3 columns for this part of program. The code can plot all y columns but just show the information of the first y colomn (line symbol and line color). The other curve just shows on the plot, but the plot doesn't indicate that the curve use what kind of symbols or color to plot.

Hope these words could help you understand what I mean.

Kander

Edited by - kanderlee on 09/26/2007 04:51:47 AM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/26/2007 :  08:29:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Do you want to recreate the legend (circled in red below)? Add gly.LT_execute("legend"); after gly.Rescale();



Mike Buess
Origin WebRing Member
Go to Top of Page

kanderlee

Taiwan
Posts

Posted - 09/26/2007 :  11:50:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes! This function is that I really want to use. Thank you!

If I want to plot all curves on the same layer, how could I modify the code?

Kander
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 09/27/2007 :  09:09:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
If I want to plot all curves on the same layer, how could I modify the code?
The GraphPage and GraphLayer lines should appear before the FOR loop and GroupPlots(), Rescale(), LT_execute("legend") should appear after the FOR loop.

Mike Buess
Origin WebRing Member
Go to Top of Page

kanderlee

Taiwan
Posts

Posted - 09/29/2007 :  05:07:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply


Origin C programing is a challenging mission for me because I don't really know what command can be used for my need. So the MOST difficult part of programing Origin C for me is knowing the specified commands of Origin in Origin C.

After your help, I've got to understand a little bit about Origin C.

Thank you again.
Go to Top of Page

rusen

USA
Posts

Posted - 10/14/2007 :  7:20:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have some problem with this script when the file name is long. For example, when the name is short, I might be able to import 10 at the same time (but failed with even more file). When the file name is very long (such as 71010-No2-IV-p5V-forward-after It measurement 001.dat), I can only import 3 files as maximum. After I change the file to shorter name, then I can import more file. Could you help me with that?

Thanks,



quote:

quote:
I only want to use the file names I imported as the Worksheet and Graphplot names instead of file path.
string strLabel = GetFileName(strFile); // strip path
wks.GetPage().Label = strLabel; // set worksheet label
// ...
gpg.Label = strFile; // set graph label

Mike Buess
Origin WebRing Member

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/14/2007 :  9:18:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi rusen,

You must have an early build of O75 for which GetMultiOpenBox() had problems...
http://www.originlab.com/forum/topic.asp?TOPIC_ID=4443

Run Help> Check for Updates and update to the latest build (SR6).

Mike Buess
Origin WebRing Member
Go to Top of Page

rusen

USA
Posts

Posted - 10/15/2007 :  11:30:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Now it works great. Thank you very much!

quote:

Hi rusen,

You must have an early build of O75 for which GetMultiOpenBox() had problems...
http://www.originlab.com/forum/topic.asp?TOPIC_ID=4443

Run Help> Check for Updates and update to the latest build (SR6).

Mike Buess
Origin WebRing Member

Go to Top of Page

rusen

USA
Posts

Posted - 10/15/2007 :  1:12:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
May I ask more questions because I have tried for a while and cannot find the answer?

I want to do the following.

I import multiple data files with the file name as label. The data file has the first colunm as time, second current, and second voltage. and I want to plot two kinds of curve, Current vs. Time, Or Current vs Voltage.

Because the current is very small, 10^-9-10^-12. As a result, I always manually add two columns and set one column equals voltage and the other column equals to current*10^6, current*10^9, or current 10^12. The factor (10^6,10^9, 10^12) depends on the current level, such that I will not get long number( such as 0.000023, or 234567) on the y axis. At the same time I will label the y axis as Current (microampere), or Current (nanoampere), or Current (picoamplere) according. The X axis will be Voltat (V) or Time (second).

In addition, it will be great if the graph have the same label and similiar name as the worksheet.

I studied the help file for a while but I cannot even add column to the worksheet with "Worksheet -a 2" or some other codes. To find the suitable fact will definitly beyord what I can do.

I hope you can help me out.

By the way, I also attached two examples
Thanks,
Rusen



quote:

Hi rusen,

You must have an early build of O75 for which GetMultiOpenBox() had problems...
http://www.originlab.com/forum/topic.asp?TOPIC_ID=4443

Run Help> Check for Updates and update to the latest build (SR6).

Mike Buess
Origin WebRing Member

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/15/2007 :  5:20:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
it will be great if the graph have the same label and similiar name as the worksheet.
You'll have to explain what you mean by "similar name" but "same label" just requires a slight modification to my earlier script...

string strLabel = GetFileName(strFile); // strip path
wks.GetPage().Label = strLabel; // set worksheet label
// ...
gpg.Label = strLabel; // set graph same label.

quote:
I studied the help file for a while but I cannot even add column to the worksheet with "Worksheet -a 2" or some other codes.
worksheet -a 2 is a LabTalk command that works from the script window. Search for AddCol in the index of the programming guide to learn about the equivalent Origin C function. I'm not sure what else you're asking for but this might help...

Worksheet wks = Project.ActiveLayer(); // active worksheet
int iCol = wks.AddCol(); // add one column and save its index as iCol
Dataset ds1(wks,1); // create dataset from column 2
Dataset ds2(wks,iCol-1); // create dataset from column iCol
ds2 = ds1 * 1.0E6; // copy column 2 to column iCol and multiply by 10^6
Curve crv(wks,iCol-1); // create curve from column iCol
GraphPage gpg;
gpg.Create("Origin.otp"); // create graph from default template
GraphLayer gl = gpg.Layers(0);
gl.AddPlot(crv); // plot curve in graphlayer
GraphObject goX = gl.GraphObjects("XB");
goX.Text = "Time (second)"; // set bottom axis title
GraphObject goY = gl.GraphObjects("YL");
goY.Text = "Current (microampere)"; // set left axis title

Mike Buess
Origin WebRing Member
Go to Top of Page

rusen

USA
Posts

Posted - 10/15/2007 :  6:05:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much to clarify the Labtalk. I had thought they all works in the script!

If the graph has the same label as the worksheet, I should be able to identify them easily. The Name is not critical. The similiar means that if the worksheet has a name Data5, it will better to name the graph as Graph5, such that I can easily know Graph5 comes from Data 5.

The most difficult for me is how to find the suitble factor for the current. Some data file has the current mostly in the (10^-10 to 10^-12) range, some data file in the (10^-7 to 10^-9) range, and some in (10^-4-10^-6) range. For the first kind file I might need "ds2 = ds1 * 1.0E12", the second "ds2 = ds1 * 1.0E9", and the last will be "ds2 = ds1 * 1.0E6". I can do it manually after import the data into the worksheet one by one. It's really time-consuming when I have to deal with so many files. Is there a way to find the suitable factor (1.0E12, 1.0E9, or 1.0E6) during the import based on the current value and plot the curve correpondingly?

In addition, when I plot Current-Voltage curve, I will have to copy column 2 (current) and column 3 (voltage) to two new columns, set the new voltage column as X2 and new current column as Y2, and then plot a curve Y2-X2 (i.e. Current-Voltage). Could you give some hint on this as well?

I usually plot curve with mine theme, which has been set as system theme. How to get the new plot with the theme?

By the way, I have three columns in my worksheet. In order to avoiding erase the third columns, I have to modify your code from

Dataset ds2(wks,iCol-1); // create dataset from column iCol
ds2 = ds1 * 1.0E6; // copy column 2 to column iCol and multiply by 10^6
Curve crv(wks,iCol-1); // create curve from column iCol
GraphPage gpg;

to
Dataset ds2(wks,iCol); // create dataset from column iCol
ds2 = ds1 * 1.0E6; // copy column 2 to column iCol and multiply by 10^6
Curve crv(wks,iCol); // create curve from column iCol
GraphPage gpg;

Additionally, can I rescale automatically the axis after the plot such that I can the whole curve? After running give script, the scale always (0,10) for x and (0,10) for y.

Thank you so much for your effort!
Rusen


quote:

quote:
it will be great if the graph have the same label and similiar name as the worksheet.
You'll have to explain what you mean by "similar name" but "same label" just requires a slight modification to my earlier script...

string strLabel = GetFileName(strFile); // strip path
wks.GetPage().Label = strLabel; // set worksheet label
// ...
gpg.Label = strLabel; // set graph same label.

quote:
I studied the help file for a while but I cannot even add column to the worksheet with "Worksheet -a 2" or some other codes.
worksheet -a 2 is a LabTalk command that works from the script window. Search for AddCol in the index of the programming guide to learn about the equivalent Origin C function. I'm not sure what else you're asking for but this might help...

Worksheet wks = Project.ActiveLayer(); // active worksheet
int iCol = wks.AddCol(); // add one column and save its index as iCol
Dataset ds1(wks,1); // create dataset from column 2
Dataset ds2(wks,iCol-1); // create dataset from column iCol
ds2 = ds1 * 1.0E6; // copy column 2 to column iCol and multiply by 10^6
Curve crv(wks,iCol-1); // create curve from column iCol
GraphPage gpg;
gpg.Create("Origin.otp"); // create graph from default template
GraphLayer gl = gpg.Layers(0);
gl.AddPlot(crv); // plot curve in graphlayer
GraphObject goX = gl.GraphObjects("XB");
goX.Text = "Time (second)"; // set bottom axis title
GraphObject goY = gl.GraphObjects("YL");
goY.Text = "Current (microampere)"; // set left axis title

Mike Buess
Origin WebRing Member



Edited by - rusen on 10/15/2007 6:10:08 PM

Edited by - rusen on 10/15/2007 6:45:17 PM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/16/2007 :  1:08:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I think you are making this too difficult. First of all, you can adjust the tick labels without actually normalizing the data. Second, when plotting from Origin C the column used as X axis does not need to be an X column, nor must it be to the left of the Y column. Consequently there is no need to copy data to new columns and normalize.

The following code shows two methods for formatting the tick labels. Method 1 changes the numeric format to Engineering where each label is automatically given the suffix m, μ, n or p. Method 2 applies a normalization factor to the tick labels. Since you have to find that factor this method is much more tedious. Note: you might be able to come up with a better way to arrive at the normalization factor than the one I used.

The code also rescales and applies your theme (MyTheme.oth) as requested.

Worksheet wks = Project.ActiveLayer();
Curve crv(wks,2,1); // create curve with voltage col as X and current col as Y
GraphPage gpg;
gpg.Create("Origin.otp"); // create graph page from default template
GraphLayer gl = gpg.Layers(0);

gl.AddPlot(crv); // plot curve
gl.Rescale(); // rescale to show all data
string sYTitle = "Current (A)"; // Y axis title

// Method 1 - set label format to engineering
gl.LT_execute("layer.y.label.numformat = 3");


// Method 2 - normalize labels
double dY = 1.0; // normalization factor
double dY2 = gl.Y.To; // max value of Y range
if( dY2<1 )
{
dY *= 1E-3;
sYTitle = "Current (mA)"; // milliamp
}
if( dY2<1E-3 )
{
dY *= 1E-3;
sYTitle = "Current (\g(m)A)"; // microamp
}
if( dY2<1E-6 )
{
dY *= 1E-3;
sYTitle = "Current (nA)"; // nanoamp
}
if( dY2<1E-9 )
{
dY *= 1E-3;
sYTitle = "Current (pA)"; // picoamp
}
gl.LT_execute("layer.y.label.divideby = " + dY);


// Set axis titles
GraphObject goY = gl.GraphObjects("YL");
goY.Text = sYTitle; // Y axis title
GraphObject goX = gl.GraphObjects("XB");
goX.Text = "Voltage (V)"; // X axis title

// Apply theme
gpg.ApplyFormat("themes\\MyTheme.OTH");


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/16/2007 1:20:41 PM
Go to Top of Page

rusen

USA
Posts

Posted - 10/16/2007 :  3:52:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you so much, Mike! I fininally composed the script I want! You will save me a lot of time, which can be used to more important things.
Go to Top of Page

rusen

USA
Posts

Posted - 10/18/2007 :  12:11:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,

I have some minor questions.

1, I want to solve some problem by myself but cannot find the result from help file. Do you have any suggestions?

For example, I want to get rid of the legend. I spent a long time to search "legend" in the help file, but I have never got related information. From somewhere in the forum, I occasionlly find a script, something like "legend.=". When I type it in the script window, I got a list of scripts, such as x, y, width,show, etc. Unfortunally, I didn't get any explanations. I just tried legend.show=0, and it works! So I included the following two lines in my program
gl.LT_execute("legend");
gl.LT_execute("legend.show=0"); // Get rid of legend

By the way, "legend.=" is not the right format. What's the right format to get more information in the sript window? I cannot find it today.

2, How can I format the lable, such as BOLD

The following script creat the xtitle and y title.
GraphObject goY = gl.GraphObjects("YL");
goY.Text = sYTitle; // Y axis title
GraphObject goX = gl.GraphObjects("XB");
goX.Text = "Time (Second)"; // X axis title

I want to make the title to be bold, then add another line.
gpg.LT_execute("label -xb \\b(Time (Second))");
this line creat the bottom x tile and set the format at the same time. For the y title, I have to repeat silimiar script many times because y-title can be different name.

Is there a way to set the format without consider the content? I mean I can creat the title first and the then set the format later.

3 about the theme. I try to make the xtitle to be bold with theme. When I check the TEXT when I save theme, the theme will apply the content to new graph. I mean the graph will have the same name besides the format. When I uncheck the the TEXT, the theme will do nothing to the format. Is there a way to set the format only with the theme?

In the detail I can see "\b(Time (Second))" when the text is checked. I changed it to "\b()", but I will get nothing at the x title.

Thank you!



Edited by - rusen on 10/18/2007 12:21:43 PM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/18/2007 :  12:36:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
1. The legend is just a text label named legend and can be deleted with label -r legend. Note that legend.show=0 only hides the legend. It can be restored with legend.show=1. And entering legend.= in the script window is indeed the correct way to obtain its properties (see bottom).

2. This shows the X and Y axis titles in boldface...

GraphObject goY = gl.GraphObjects("YL");
goY.Text = "\\b(" + sYTitle + ")"; // Y axis title
GraphObject goX = gl.GraphObjects("XB");
goX.Text = "\\b(Time (Second))"; // X axis title



Mike Buess
Origin WebRing Member
Go to Top of Page

rusen

USA
Posts

Posted - 10/18/2007 :  6:49:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It's really strange. I type the same script "legend.=" in the script window thin morning but I only got "LEGEND.=--;" I had thought I type in the wrong format. Now I copy the same script script "lengend.=" and click return, then I got all the properties.

Additionally, how can I set the format only of the title with theme?

I think asking in the forum is much easier than searching the help file. I have searched in the help file for a long time without any result. With this forum, I can get it the same day, or overnight at the lastest.

If you can give me some suggestion on how to easily take advantage of the help file and find the solution quickly, I will be very happy. I really don't want, don't have time, to read all the help file from the first page to the last.

Thank you so much!

quote:

1. The legend is just a text label named legend and can be deleted with label -r legend. Note that legend.show=0 only hides the legend. It can be restored with legend.show=1. And entering legend.= in the script window is indeed the correct way to obtain its properties (see bottom).

2. This shows the X and Y axis titles in boldface...

GraphObject goY = gl.GraphObjects("YL");
goY.Text = "\\b(" + sYTitle + ")"; // Y axis title
GraphObject goX = gl.GraphObjects("XB");
goX.Text = "\\b(Time (Second))"; // X axis title



Mike Buess
Origin WebRing Member

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/19/2007 :  12:12:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
I type the same script "legend.=" in the script window thin morning but I only got "LEGEND.=--;" I had thought I type in the wrong format. Now I copy the same script script "lengend.=" and click return, then I got all the properties.
Object.= only works if Object exists. If a worksheet or graph window with no legend is active there is no legend or legend properties (LEGEND.=--).

quote:
how can I set the format only of the title with theme?
To save the text in all text labels in active graph layer, uncheck All and check Text in the dialog below...


To learn about general user-created object properties (such as legend) search for User-created Visual Objects in the programming guide.

Mike Buess
Origin WebRing Member
Go to Top of Page

rusen

USA
Posts

Posted - 10/19/2007 :  10:37:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry I didn't say the question clearly.

What I want to do with the theme is the format (or style) of the text not the content. In other words, I want the text to be bold and 36 of font size regardless the content. For example, if I have "Time (second)" as x title and save the theme with "text" check and apply this theme to a new graph with x title "Voltage (V)", the theme will change this x title from "Voltage (V)" to "Time (second)" instead of just change the style to be bold and fontsize to be 36.

quote:

quote:
I type the same script "legend.=" in the script window thin morning but I only got "LEGEND.=--;" I had thought I type in the wrong format. Now I copy the same script script "lengend.=" and click return, then I got all the properties.
Object.= only works if Object exists. If a worksheet or graph window with no legend is active there is no legend or legend properties (LEGEND.=--).

quote:
how can I set the format only of the title with theme?
To save the text in all text labels in active graph layer, uncheck All and check Text in the dialog below...


To learn about general user-created object properties (such as legend) search for User-created Visual Objects in the programming guide.

Mike Buess
Origin WebRing Member

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/19/2007 :  12:05:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
I want the text to be bold and 36 of font size regardless the content.
Attributes such as bold, italics, subscript, superscript, etc., are part of the text, not separate styles. (See the Text Formatting.opj project in the Samples\Graphing\Miscellaneous folder.) The X title Voltage (V) is saved to theme as "\b(Voltage (V))". Check it out yourself by clicking the Edit button in the Save Format as Theme dialog. Select All Styles in the theme dialog to save font size.

Mike Buess
Origin WebRing Member
Go to Top of Page

kanderlee

Taiwan
Posts

Posted - 10/24/2007 :  10:18:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, Mike,

I'm coming back....

I have a question realted to the code which you posted on this topic to ask for your help.

After excuting the code, all of graphpages are separated.


If I want this code to create this kind of graphpage:

(Precisely speaking, I want show all the graphs by one column in one graphpage.)



how to modify the code?

And if I want to make chooses for users to chose one of these two graphpage styles to show the graph, what code can I add? Thank you.

Kander Lee
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/26/2007 :  08:44:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Easiest solution is Edit> Merge all Graph Windows. (First minimize all graphs you don't want to merge.) That will create the graph you want without changing the code.

Mike Buess
Origin WebRing Member
Go to Top of Page

kanderlee

Taiwan
Posts

Posted - 10/30/2007 :  10:15:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This is truely the easiest way to achieve the function which I want to realize. Thank for your suggestion.

I've used AppendLayers, LT_execute("CheckMargins"), LT_execute("ArrangeLayers") to make that function, and it's also useful but spent me a lot of time to make it.

I have a qutestion to ask you. ^^"

If I just want to show the column's name on the plot (only the text of "legend"), how can I do? Thank you.


Kander Lee



quote:

Easiest solution is Edit> Merge all Graph Windows. (First minimize all graphs you don't want to merge.) That will create the graph you want without changing the code.

Mike Buess
Origin WebRing Member



Edited by - kanderlee on 10/30/2007 11:32:15 PM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 10/31/2007 :  02:03:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

GraphPage gp = Project.GraphPages(-1);
foreach (GraphLayer lay in gp.Layers)
{
DataPlot dp = lay.DataPlots(0);
string str = dp.GetDatasetName();
GraphObject go = lay.GraphObjects("legend");
go.Text = str.GetToken(1,'_');
}
gp.Refresh();

Mike Buess
Origin WebRing Member
Go to Top of Page

kanderlee

Taiwan
Posts

Posted - 10/31/2007 :  05:45:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It works great!

Thank you, Mike.

Kander Lee
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