T O P I C R E V I E W |
bleble1717 |
Posted - 10/27/2006 : 08:40:13 AM Origin Version (Select Help-->About Origin): 7.5 Operating System: Win XP
Hi.
I have over 600 files containing 2 columns X and Y. Is it possible to draw 20-30 graphs a page each cantaining data from one file with reversed Y axis and legend showing name of each file ? |
25 L A T E S T R E P L I E S (Newest First) |
Mike Buess |
Posted - 02/01/2007 : 09:58:24 AM Hi Radnar,
Sorry, I still can't duplicate your problem. ImportToPanelGraphs works for me with data, list and template in different directories.
Mike Buess Origin WebRing Member |
rdrnnr.pl |
Posted - 02/01/2007 : 09:02:49 AM Hi Mike
Adjustments You made didnt work so I had to get creative and after several hours I found out that it works but only if files, template and list are in the same directory. Dont know why and I dont care but it finally works.
Thanks for Your help and all Your hard work
Radnar. |
Mike Buess |
Posted - 01/30/2007 : 5:06:57 PM I can't reproduce your template problem so maybe you made a mistake on copy/paste. I did see a minor error with legends and fixed that below. I've been having problems posting these code so I've saved it to file and uploaded to my web site. Hopefully that link will work! (I renamed the function so it won't interfere with previous code.)
http://www.nmrtools.com/forum/ImportToPanelGraphs.c
Mike Buess Origin WebRing Member |
Mike Buess |
Posted - 01/30/2007 : 3:33:58 PM Since the panels are built into the template you'll have to delete them yourself. Just add this after the main loop.
for(i=nLayers-1;i>=0;i--) { GraphLayer gl = gp.Layers(i); if( !gl.DataPlots.Count() ) gl.Destroy(); } gp.Refresh();
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 01/30/2007 3:35:41 PM |
rdrnnr.pl |
Posted - 01/30/2007 : 3:01:13 PM Hi Thanks for answer I don't think thats a part of my problem because I changed it only in previous version. What do I mean by not to show empty panels : let's say that template consists of 16 panels and there are 20 files to be plotted the outocome will be 2 pages : 1 with 16 graphs and the other with 4 graphs and 12 empty panels. What needs to be added to erase empty panels automatically? |
Mike Buess |
Posted - 01/30/2007 : 2:44:26 PM quote: if(TRGP_STR_BUTTON == nType && nRow == 4) // 4 has to be chnged to 3 and it works just fine
I notice that too but it adding the File List button changed it back to 4 in current version. Perhaps that's part of your problem.
quote: what has to added to the script so it doesnt show empty panels?
Not sure what you mean.
I'll look into the template problem.
Mike Buess Origin WebRing Member |
rdrnnr.pl |
Posted - 01/30/2007 : 1:44:30 PM Hi Mike Thanks for help. The good news is almost everything works, but the bad news is there are some problems with script. It works but only partially. What I mean is it works only when I leave the temaplate field blank but then it plots every file separately, when I try to use any template all I get is empty worksheets and I get 60 - 70 copies of template? Why is that? I think theres sth wrong with importing template becaue files are fine template itself is fine - they work with previous scripts
You think You can do sth about it?
By the way previous script (Posted - 01/28/2007 : 10:43:37 AM) doesnt work either but I found the reason why :
if(TRGP_STR_BUTTON == nType && nRow == 4) // 4 has to be chnged to 3 and it works just fine
One more thing : what has to added to the script so it doesnt show empty panels?
Once agin thanks for Your help
Radnar |
Mike Buess |
Posted - 01/29/2007 : 2:18:25 PM Hi Radnar,
This should do it. The initial dialog asks you to find the file list.
#include <GetNBox.h>
static string sFileList; static string sTemplateName; static string xTitle,yTitle; static int fSize;
void ImportToPanels2() { if( xTitle.IsEmpty() ) xTitle = "X Axis Title"; if( yTitle.IsEmpty() ) yTitle = "Y Axis Title"; if( !fSize ) fSize = 22; GETN_TREE(tr) GETN_OPTION_GRIDLINE(flexGridFlatVert) GETN_STR(xtitle, "X Axis Title", xTitle) GETN_STR(ytitle, "Y Axis Title", yTitle) GETN_NUM(fsize, "Font Size", fSize) GETN_BUTTON(filelist, "File List", sFileList) GETN_OPTION_EVENT(file_list_event) GETN_BUTTON(template, "Template Name", sTemplateName) GETN_OPTION_EVENT(template_event) if( GetNBox(tr, "Import to Panels", NULL, NULL, NULL) ) { xTitle = tr.xtitle.strVal; yTitle = tr.ytitle.strVal; fSize = tr.fsize.nVal; sFileList = tr.filelist.strVal; sTemplateName = tr.template.strVal; } else return; string strTemp; StringArray saFiles; stdioFile ff; ff.Open(sFileList, file::modeRead); int n; while( ff.ReadString(strTemp) ) { n++; printf("%d: %s\n",n,strTemp); saFiles.Add(strTemp); } ff.Close(); if( !saFiles.GetSize() ) return; ASCIMP ascimp; AscImpReadFileStruct(saFiles[0], &ascimp); ascimp.iMode = ASCIMP_MODE_REPLACE_DATA; ascimp.iRenameWks = false; ascimp.iRenameCols = false; Worksheet wks; GraphPage gp; gp.Create(sTemplateName); int nLayers = gp.Layers.Count(); for(int i=0; i<saFiles.GetSize(); i++) { int j = mod(i,nLayers); if( !j && i ) gp.Create(sTemplateName); wks.Create("Origin.otw"); wks.ImportASCII(saFiles[i], ascimp); wks.Columns(2*j).SetType(OKDATAOBJ_DESIGNATION_X); wks.GetPage().Label = saFiles[i]; wks.GetPage().LT_execute("page.title=3"); wks.GetPage().GetWindow().ShowWindow(SW_MINIMIZE); string str = saFiles[i].GetToken(0,'.'); GraphLayer gl = gp.Layers(j); gl.AddPlot(wks,IDM_PLOT_SCATTER); gl.LT_execute("layer.y.reverse=1"); gl.LT_execute("layer.x.showAxes=2;"); gl.LT_execute("layer.x2.showLabels=2;"); gl.Rescale(); gl.LT_execute("legend.text$=" + str); gl.LT_execute("legend.fsize=" + fSize); gl.LT_execute("legend.x = (x2-x1)/2"); gl.LT_execute("legend.y = y1 - legend.dy/2"); gl.LT_execute("label -r xb"); gl.LT_execute("label -xt " + xTitle); gl.LT_execute("xt.fsize=" + fSize); gl.LT_execute("yl.text$=" + yTitle); gl.LT_execute("yl.fsize=" + fSize); gp.GetWindow().ShowWindow(SW_NORMAL); } } bool file_list_event(TreeNode& tr, int nRow, int nType, Dialog& theDlg) { if(TRGP_STR_BUTTON == nType && nRow == 3) { string sFileList = GetOpenBox("*.txt Text Files",GetAppPath(),sFileList,"Find File List"); if( sFileList.IsEmpty() ) return false; tr.filelist.strVal = sFileList; return true; } else return false; } bool template_event(TreeNode& tr, int nRow, int nType, Dialog& theDlg) { if(TRGP_STR_BUTTON == nType && nRow == 4) { string sTemplate = GetOpenBox("*.otp Graph Templates",GetAppPath(),sTemplateName,"Find Panel Graph Template"); if( sTemplate.IsEmpty() ) return false; tr.template.strVal = sTemplate; return true; } else return false; }
Mike Buess Origin WebRing Member |
rdrnnr.pl |
Posted - 01/29/2007 : 12:05:10 PM Thanks for answer, You've done great job on this but I don't think it'll work for me. But I didnt try it yet. Sorting order is .... well it's hard to explain but here's a part of table in Word :
... file7259 dat73763 fix80295 fix8535 var881095 dat952139 file95836 var135516 dat147383 fix151317 var102615 dat121409 dat106446 file178998 var113309 var113601 fix116600 dat119318 fix123322 fix127601 ...
this is the order files are created : file1....xxx, var1...xxx, dat1....xxx, mid1...xxx and whet it comes to size it's usually : varx>datx>filex>midx
So what I need (I think) is a script that imports a file lets's say "list.txt" that contains more than less sth like this :
... c:\...\file7259.dat c:\...\dat7263.dat c:\...\fix80295.dat c:\...\fix8535.dat ...
and plots them in order they are on the list Do You think it's possible to do it?
Again thanks for Your help
Radnar
Edited by - rdrnnr.pl on 01/29/2007 12:06:02 PM |
Mike Buess |
Posted - 01/28/2007 : 10:43:37 AM You say that bleble1717's sorting doesn't work for you but you don't say how you need to sort. Therefore, the function at the bottom lists selected files in a multiple file selection dialog in which you can sort by file name, size or modification date by clicking on the appropriate column heading.
quote: is there a simple way to export all graphs to bmp or jpg etc. to certain catalog
http://www.originlab.com/ftp/programming/ExportAllGraphsToBMP.c
You can also use the ProjectCatalog addon. All image files are exported to the Catalog subfolder on your User path.
quote:
points are represented by black squares size 9 can it be changed (to black circles size 5) when creating template
Just change the point sizes on one graph, right-click on the graph window's title bar and select Save Template.
#include <GetNBox.h>
static string sTemplateName; static string xTitle,yTitle; static int fSize;
void ImportToPanels() { if( xTitle.IsEmpty() ) xTitle = "X Axis Title"; if( yTitle.IsEmpty() ) yTitle = "Y Axis Title"; if( !fSize ) fSize = 22; GETN_TREE(tr) GETN_OPTION_GRIDLINE(flexGridFlatVert) GETN_STR(xtitle, "X Axis Title", xTitle) GETN_STR(ytitle, "Y Axis Title", yTitle) GETN_NUM(fsize, "Font Size", fSize) GETN_BUTTON(template, "Template Name", sTemplateName) GETN_OPTION_EVENT(template_event) if( GetNBox(tr, "Import to Panels", NULL, NULL, NULL) ) { xTitle = tr.xtitle.strVal; yTitle = tr.ytitle.strVal; fSize = tr.fsize.nVal; sTemplateName = tr.template.strVal; } else return; StringArray saFiles; GetMultiOpenBox(saFiles, FDLOG_ASCII, NULL, NULL, NULL, false); if( !saFiles.GetSize() ) return; ASCIMP ascimp; AscImpReadFileStruct(saFiles[0], &ascimp); ascimp.iMode = ASCIMP_MODE_REPLACE_DATA; ascimp.iRenameWks = false; ascimp.iRenameCols = false; Worksheet wks; GraphPage gp; gp.Create(sTemplateName); int nLayers = gp.Layers.Count(); for(int i=0; i<saFiles.GetSize(); i++) { int j = mod(i,nLayers); if( !j && i ) gp.Create(sTemplateName); wks.Create("Origin.otw"); wks.ImportASCII(saFiles[i], ascimp); wks.Columns(2*j).SetType(OKDATAOBJ_DESIGNATION_X); wks.GetPage().Label = saFiles[i]; wks.GetPage().LT_execute("page.title=3"); wks.GetPage().GetWindow().ShowWindow(SW_MINIMIZE); string str = saFiles[i].GetToken(0,'.'); GraphLayer gl = gp.Layers(j); gl.AddPlot(wks,IDM_PLOT_SCATTER); gl.LT_execute("layer.y.reverse=1"); gl.LT_execute("layer.x.showAxes=2;"); gl.LT_execute("layer.x2.showLabels=2;"); gl.Rescale(); gl.LT_execute("legend.text$=" + str); gl.LT_execute("legend.fsize=" + fSize); gl.LT_execute("legend.x = (x2-x1)/2"); gl.LT_execute("legend.y = y1 - legend.dy/2"); gl.LT_execute("label -r xb"); gl.LT_execute("label -xt " + xTitle); gl.LT_execute("xt.fsize=" + fSize); gl.LT_execute("yl.text$=" + yTitle); gl.LT_execute("yl.fsize=" + fSize); gp.GetWindow().ShowWindow(SW_NORMAL); } } bool template_event(TreeNode& tr, int nRow, int nType, Dialog& theDlg) { if(TRGP_STR_BUTTON == nType && nRow == 4) { string sTemplate = GetOpenBox("*.otp Graph Templates",GetAppPath(),sTemplateName,"Find Panel Graph Template"); if( sTemplate.IsEmpty() ) return false; tr.template.strVal = sTemplate; return true; } else return false; }
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 01/28/2007 10:53:31 AM |
rdrnnr.pl |
Posted - 01/26/2007 : 2:27:27 PM quote:
There are several different scripts under this topic. Which one are you talking about?
Mike Buess Origin WebRing Member
Hi Thanks for answer Thisone :
Posted - 10/30/2006 : 10:14:40 PM
void ImportToPanels()
Edited by - rdrnnr.pl on 01/27/2007 3:11:28 PM |
Mike Buess |
Posted - 01/26/2007 : 2:23:56 PM There are several different scripts under this topic. Which one are you talking about?
Mike Buess Origin WebRing Member |
rdrnnr.pl |
Posted - 01/26/2007 : 2:11:32 PM Origin Version (Select Help-->About Origin): 7.5 Operating System: Win XP
Hi everyone
I found this script (by the way great job guys) and I'm wondering can it be modified so instead of data folder it imports sth like a file (list) with paths to files or filenames (files are in 1 catalogue but I can put them in several catologues - it doesn' matter) or whatever, couse I seem to have the same problem bleble1717 had - files have to be ploted in certain order but these sorting functions don't work for me. 1 more thing or 2 actually is there a simple way to export all graphs to bmp or jpg etc. to certain catalogue couse it takes so long to save each manually (I get 60 - 70) and the other thing points are represented by black squares size 9 can it be changed (to black circles size 5) when creating template couse I cant find it anywhere and have to change all 60 -70 graphs manually after they are plotted. |
Mike Buess |
Posted - 11/07/2006 : 12:28:31 PM I'm guessing that you really want to import the files in the order they were created in which case the function below should help. (If you truly want to reorder by file name then maybe someone else can show you how.) Add the SortByDate function to your OC file and call it by inserting the (brown) line into the ImportToPanels function where shown...
// Call sorting function from ImportToPanels StringArray saFiles; FindFiles(saFiles, sDataPath, "dat"); if( !saFiles.GetSize() ) return; SortByDate(saFiles); ASCIMP ascimp;
// Sorting function void SortByDate(StringArray& sa) { WorksheetPage wpg; wpg.Create("Origin.otw",CREATE_TEMP); Worksheet wks = wpg.Layers(0); WIN32_FILE_ATTRIBUTE_DATA fileInfo; FILETIME localFiletime; SYSTEMTIME sysTime; string strDate; for(int i=0; i<sa.GetSize(); i++) { GetFileAttributesEx(sDataPath + sa[i], 0, &fileInfo); FileTimeToLocalFileTime(&fileInfo.ftLastWriteTime, &localFiletime); FileTimeToSystemTime(&localFiletime, &sysTime); strDate.Format("%4d.%.2d.%.2d.%.2d.%.2d.%.2d", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond); wks.SetCell(i,1,strDate); } Dataset dd(wks,0); dd.PutStringArray(sa); wks.Sort(1); dd.GetStringArray(sa); }
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 11/07/2006 12:32:08 PM |
zachary_origin |
Posted - 11/07/2006 : 12:16:09 PM Add the two functions below to the file and add sort_the_files(saFiles); following the lines of StringArray saFiles; FindFiles(saFiles, sDataPath, "dat"); if( !saFiles.GetSize() ) return;
////--------------- static void sort_the_files( StringArray & saFiles ) { string strTemp; for (int ii = 1; ii < saFiles.GetSize(); ii++) { // insert sort. if ( !IsLessThan( saFiles[ii], saFiles[ii-1]) ) ii++; // saFile[ii] > saFile[ii-1] else { strTemp = saFiles[ii]; int jj = ii; while (jj > 0 && IsLessThan(strTemp, saFiles[jj-1])) { saFiles[jj] = saFiles[jj-1]; jj--; } saFiles[jj] = strTemp; } } }
static bool IsLessThan( string strA, string strB ) { strA = strA.GetToken(0, '.'); //get file name without extension strB = strB.GetToken(0, '.'); string strA1 = strA.GetToken(0, '_'); //get the first number string strA2 = strA.GetToken(1, 'p'); //get the second number string strB1 = strB.GetToken(0, '_'); string strB2 = strB.GetToken(1, 'p'); int nA1 = atoi(strA1); int nA2 = atoi(strA2); int nB1 = atoi(strB1); int nB2 = atoi(strB2); if( nA1 < nB1 ) return true; else if (nA1 > nB1) return false; else // nA1 == nB1 { if( nA2 < nB2 ) return true; else if (nA2 > nB2) return false; else // nA2 == nB2 impossible? return true; } }
///--------------
Zachary OriginLab Technical Services. |
bleble1717 |
Posted - 11/07/2006 : 09:23:30 AM You are amazing! Thank's for you effort It works great. Thank you VERYMUCH !!!
Sorry to bug you but I have 1 more question My filenames are numbers (various from 1 to 336441) and when I plot them I get strange order : 1,10,11,12,...,19,2,20,21... etc and so file 139832.dat is plotted before 8938.dat probably 'couse they're imported by name Is is possible to sort them by numbers when : a)filename is a number : 4456.dat b)filename is a number+sth : 4456_p0,999.dat
Edited by - bleble1717 on 11/07/2006 09:30:46 AM |
zachary_origin |
Posted - 10/30/2006 : 10:14:56 PM quote: And one more thing if you'd be so kind : The X Axis in yor script is on top I'd like it to be on bottom
Add the following two lines before the line of gl.Rescale();
gl.LT_execute("layer.x.showAxes=2;"); gl.LT_execute("layer.x2.showLabels=2;");
Zachary OriginLab Technical Services. |
Mike Buess |
Posted - 10/30/2006 : 10:14:40 PM #include <GetNBox.h>
static string sDataPath,sTemplateName; static string xTitle,yTitle; static int fSize;
void ImportToPanels() { if( xTitle.IsEmpty() ) xTitle = "X Axis Title"; if( yTitle.IsEmpty() ) yTitle = "Y Axis Title"; if( !fSize ) fSize = 22; GETN_TREE(tr) GETN_OPTION_GRIDLINE(flexGridFlatVert) GETN_STR(xtitle, "X Axis Title", xTitle) GETN_STR(ytitle, "Y Axis Title", yTitle) GETN_NUM(fsize, "Font Size", fSize) GETN_BUTTON(path, "Data Folder", sDataPath) GETN_OPTION_EVENT(path_event) GETN_BUTTON(template, "Template Name", sTemplateName) GETN_OPTION_EVENT(template_event) if( GetNBox(tr, "Import to Panels", NULL, NULL, NULL) ) { xTitle = tr.xtitle.strVal; yTitle = tr.ytitle.strVal; fSize = tr.fsize.nVal; sDataPath = tr.path.strVal; sTemplateName = tr.template.strVal; } else return; StringArray saFiles; FindFiles(saFiles, sDataPath, "dat"); if( !saFiles.GetSize() ) return; ASCIMP ascimp; AscImpReadFileStruct(sDataPath + saFiles[0], &ascimp); ascimp.iMode = ASCIMP_MODE_REPLACE_DATA; ascimp.iRenameWks = false; ascimp.iRenameCols = false; Worksheet wks; GraphPage gp; gp.Create(sTemplateName); int nLayers = gp.Layers.Count(); for(int i=0; i<saFiles.GetSize(); i++) { int j = mod(i,nLayers); if( !j && i ) gp.Create(sTemplateName); wks.Create("Origin.otw"); wks.ImportASCII(sDataPath + saFiles[i], ascimp); wks.Columns(2*j).SetType(OKDATAOBJ_DESIGNATION_X); wks.GetPage().Label = saFiles[i]; wks.GetPage().LT_execute("page.title=3"); wks.GetPage().GetWindow().ShowWindow(SW_MINIMIZE); string str = saFiles[i].GetToken(0,'.'); GraphLayer gl = gp.Layers(j); gl.AddPlot(wks,IDM_PLOT_SCATTER); gl.LT_execute("layer.y.reverse=1"); gl.LT_execute("layer.x.showAxes=2;"); gl.LT_execute("layer.x2.showLabels=2;"); gl.Rescale(); gl.LT_execute("legend.text$=" + str); gl.LT_execute("legend.fsize=" + fSize); gl.LT_execute("legend.x = (x2-x1)/2"); gl.LT_execute("legend.y = y1 - legend.dy/2"); gl.LT_execute("label -r xb"); gl.LT_execute("label -xt " + xTitle); gl.LT_execute("xt.fsize=" + fSize); gl.LT_execute("yl.text$=" + yTitle); gl.LT_execute("yl.fsize=" + fSize); gp.GetWindow().ShowWindow(SW_NORMAL); } }
bool path_event(TreeNode& tr, int nRow, int nType, Dialog& theDlg) { if(TRGP_STR_BUTTON == nType && nRow == 3) { string strPath = BrowseGetPath(sDataPath, "Find Data Folder"); if( strPath.IsEmpty() ) return false; tr.path.strVal = strPath; return true; } else return false; }
bool template_event(TreeNode& tr, int nRow, int nType, Dialog& theDlg) { if(TRGP_STR_BUTTON == nType && nRow == 4) { string sTemplate = GetOpenBox("*.otp Graph Templates",GetAppPath(),sTemplateName,"Find Panel Graph Template"); if( sTemplate.IsEmpty() ) return false; tr.template.strVal = sTemplate; return true; } else return false; }
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/30/2006 11:10:16 PM |
Mike Buess |
Posted - 10/30/2006 : 10:13:17 PM quote: The X Axis in yor script is on top I'd like it to be on bottom
That comes from reversing the Y axis... bottom axis goes to top and top axis to bottom. It's easiest to use a graph template for this job. The following instructions create a template with 16 panels arranged in 4 columns and 4 rows.
1. Open a new graph window but do not customize.
2. Select Tools > Layer and configure the Arrange tab as follows...
Layer Arrangement: NxM Panel Columns: 4 Rows: 4 Check the Add New Layers option. Choose your Margin settings. Click the Arrange button.
3. Select File > Save Template As and save the template as Panels_4r4c.otp (4rows, 4columns) on your User path.
4. Add the Origin C code in the next post to you workspace and compile. (The code is too long to show up in this post.)
5. Call the function by entering ImportToPanels in the script window. A dialog like that below will open for label settings and file dialogs.

Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/30/2006 10:41:12 PM
Edited by - Mike Buess on 10/30/2006 11:06:50 PM |
bleble1717 |
Posted - 10/30/2006 : 12:25:10 PM Thank you very much.
Yes this is what I'm trying to get but besides revesed Y axis and legend with filename I also need plot type chang to scatter and option to change axis labels
Maybe you're right maybe 15 - 20 / page is enough they don't have to be big And one more thing if you'd be so kind : The X Axis in yor script is on top I'd like it to be on bottom
Edited by - bleble1717 on 10/30/2006 1:23:46 PM |
Mike Buess |
Posted - 10/30/2006 : 11:43:38 AM So you really want a panel graph with each panel labelled by file name. Just to make sure start with a worksheet created by the ImportTest function I gave you, select 4 or 9 Y columns (you can include the intervening X columns in the selection) and then select Plot > Panel > 4 Panel or 9 Panel. Each panel is a separate graph layer to which you can add the legend by selecting the corresponding number-icon in the upper-left corner and then Graph > New Legend. If that's the type of graph you want I can modify the ImportTest function accordingly.
...Are you sure you want 20-30 panels per page? Each will be very small.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/30/2006 12:22:50 PM |
bleble1717 |
Posted - 10/30/2006 : 11:00:20 AM Thanks four your effort but this is not what i had in mind. Maybe I din't make myself clear.
Igot something that looks moke than less like this

And what I'm trying to get is something looking like that

20 - 30 panel graph, 1panel-1file, scattered with reversed Y axis and legend with filename
Can you help me with this?
Edited by - bleble1717 on 10/30/2006 11:25:44 AM |
Mike Buess |
Posted - 10/28/2006 : 12:23:50 PM Try the following Origin C function. In case you're new to Origin C see this link for instructions. If you see compiler errors you should apply the latest service release.void ImportTest(int nCurvesPerGraph = 20) { string strPath = BrowseGetPath(NULL, "Find Data Folder"); // get data folder if( strPath.IsEmpty() ) return; StringArray saFiles; FindFiles(saFiles, strPath, "dat"); // list of files with .dat extension if( !saFiles.GetSize() ) return; ASCIMP ascimp; AscImpReadFileStruct(strPath + saFiles[0], &ascimp); ascimp.iMode = ASCIMP_MODE_APPEND_COLS; ascimp.iRenameWks = false; ascimp.iRenameCols = false; Worksheet wks; GraphPage gp; for(int i=0; i<saFiles.GetSize(); i++) { int j = mod(i,nCurvesPerGraph); if( !j ) wks.Create("Origin.otw"); wks.ImportASCII(strPath + saFiles[i], ascimp); string str = saFiles[i].GetToken(0,'.'); wks.Columns(2*j).SetType(OKDATAOBJ_DESIGNATION_X); wks.Columns(2*j).SetLabel(str); wks.Columns(2*j + 1).SetLabel(str); if ( j==nCurvesPerGraph-1 || i==saFiles.GetSize()-1 ) { wks.ShowLabels(); gp.Create(); GraphLayer gl = gp.Layers(0); gl.AddPlot(wks,IDM_PLOT_LINE); gl.LT_execute("layer.y.reverse=1"); gl.Rescale(); gl.LT_execute("legend -s"); } } }
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/28/2006 1:15:51 PM |
bleble1717 |
Posted - 10/28/2006 : 08:04:57 AM Hi Thanks for your interest
Answers : 1. Yes 2. No - values and nuber of rows are different in every file 3.Values are decreasing Y : : 0| 1| 2| 3| 4| 5|-------------------------------->X 1 2 3 4 ......
Edited by - bleble1717 on 10/28/2006 08:07:01 AM |
Mike Buess |
Posted - 10/27/2006 : 11:06:56 AM Yes, it's possible, but you need to provide more information before anyone can tell you how. Here are a few questions...
1. Are all files in the same folder? 2. Are all X columns the same? 3. What is a reversed Y axis? (Multiply Y values by -1?)
Mike Buess Origin WebRing Member |
|
|