Author |
Topic  |
|
psgst
UK
Posts |
Posted - 10/12/2006 : 04:44:01 AM
|
Hi folks. I've talked about this elsewhere but the discussion ground to a halt and I guess I needed to supply more code to give a better idea of what is going on. Basically I'm trying to resize the symbols on my LineSymbol graph, which has multiple plots that vary in number each time (depending on how many files are opened). However, the symbol size, shape, colour, etc. won't change despite using, as far as I can see, correct code. So here's the entire function that contains the graphing code from my script. If this could give anyone a clue as to why I can't change the symbol size and shape, as well as plot colour, that'd be great.
Just as a side-note, I'm aware that currently the colours I am setting are the default colours for that particular plot number.
I'm going to have to post my code into two seperate posts, but the the code is together in my script.
Cheers.
[CreateGraph] // Create the graph from the data and plot window -a multiWks; worksheet -s 1 0 $(fileCount) 0; getnumber "Bin size: " binSize "Length bin size, user must enter a value."; nCol = fileCount; iLeft = wks.c1; window -t p MULTILAYOUT; // create a new graph window %B = %H; window -r %B multiReport; window -t data MULTI; // create a new worksheet for bin percentages %B = %H; window -r %B percWks; window -t data MULTI; // create a new worksheet for binning %B = %H; window -r %B binWks; for (kk = 0; kk < nCol; kk++) // loop over the selected columns { %A = %(multiWks, iLeft +$(kk)); // dataset name of an input column sum(%A); // find max and min binMin = sum.min; binMax = sum.max;
indexCol = $(kk) + 1; col($(indexCol)) = Histogram(%A, binSize, binMin - binSize, binMax); }; // create particle frequency by percentage data for (mm = 1; mm <= wks.ncols; mm++) { sum(%(binWks,mm)); %(percWks,mm) = 100 * %(binWks,mm) / sum.total; } window -a percWks; // plot the graph worksheet -s 1 0 $(fileCount) 0; run.section(Plot, LineSymbol);
|
|
psgst
UK
Posts |
Posted - 10/12/2006 : 04:44:39 AM
|
// configure plot symbols (and size) and line colours if (fileCount => 1 && fileCount < 2) { set binWks_A -k 2; // change shape to circle set binWks_A -c 1; // line colour = black set binWks_A -z 3; // symbol size of 3 } if (fileCount => 2 && fileCount < 3) { set binWks_B -k 2; set binWks_B -c 2; // line colour = red set binWks_B -z 3; // symbol size of 3 } if (fileCount => 3 && fileCount < 4) { set binWks_C -k 2; set binWks_C -c 3; // line colour = blue set binWks_C -z 3; // symbol size of 3 } if (fileCount => 4 && fileCount < 5) { set binWks_D -k 2; set binWks_D -c 4; // line colour = dark cyan set binWks_D -z 3; // symbol size of 3 } if (fileCount => 5 && fileCount < 6) { set binWks_E -k 2; set binWks_E -c 5; // line colour = magenta set binWks_E -z 3; // symbol size of 3 } if (fileCount => 6 && fileCount < 7) { set binWks_F -k 2; set binWks_F -c 6; // line colour = dark yellow set binWks_F -z 3; // symbol size of 3 } if (fileCount => 7 && fileCount < 8) { set binWks_G -k 2; set binWks_G -c 7; // line colour = navy set binWks_G -z 3; // symbol size of 3 } if (fileCount => 8 && fileCount < 9) { set binWks_H -k 2; set binWks_H -c 8; // line colour = wine set binWks_H -z 3; // symbol size of 3 } if (fileCount => 9 && fileCount < 10) { set binWks_I -k 2; set binWks_I -c 9; // line colour = pink set binWks_I -z 3; // symbol size of 3 } if (fileCount == 10) { set binWks_J -k 2; set binWks_J -c 10; // line colour = green set binWks_J -z 3; // symbol size of 3 } document -uw; %B = %H; window -r %B multiGraph; // re-scale the graph layer -a; layer1.x.from = 0; layer1.y.from = -10; // -10 to increase clarity of points (will be -10%) // create the legend legend -s; legend.fSize = 14; // set the font size legend.text$ = %Z; legend.x1 = legend.x1 - 5; legend.y1 = legend.y1 - 4; legend.background = 1; // add a border // label the axes label -n XB \b(\p120(Particle size (profile length) microns)); label -n YL \b(\p120(Particle frequency (percentage by number))); // finally make the report the active window ready to export window -a multiReport;
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 10/12/2006 : 07:52:53 AM
|
1. The condition "greater than or equal to" is signified by ">=" rather that "=>". Your if statements will do nothing as written.
2. Once that is corrected the statements are equivalent to this...
if(fileCount==1) { set binWks_A -k 2; set binWks_A -c 1; set binWks_A -z 3; } if(fileCount==2) { set binWks_B -k 2; set binWks_B -c 2; set binWks_B -z 3; } // etc.
and will change only the last dataplot. To set the properties of all dataplots use something like this...
%Z=""; layer -c; // count dataplots and list names to %Z for(i=1; i<=count; i++) { set %[%Z,#i] -k 2; set %[%Z,#i] -z 3; set %[%Z,#i] -c i; }
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/12/2006 07:54:25 AM |
 |
|
psgst
UK
Posts |
Posted - 10/12/2006 : 08:38:48 AM
|
Hi Mike, thanks for the quick reply, I've just integrated and tested your code... the size of the symbols seems to be working, it changes now. However, the -k and -c switches don't seem to be firing. I'm trying to set all the symbols to the circle symbol, and obviously have the flexibility to set colour however it doesn't appear to be working. Can you see anything else that might suggest a reason for this?
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 10/12/2006 : 09:44:01 AM
|
Your dataplots are probably grouped to increment shape and color automatically. Ungroup the plots with layer -gu; before you set their properties.
Mike Buess Origin WebRing Member |
 |
|
psgst
UK
Posts |
Posted - 10/13/2006 : 06:53:23 AM
|
Cheers again Mike, the script is now working and in a state where I'm happy that it is finished.
However, I've tried taking it onto other PC's with Origin installed in the lab, and it's not working. Now I developed under OriginPro and I'm taking the script onto Origin standard PC's, same version (7.5) - will that make a difference?
Also, is there any kind of configuration changes I'd need to make in order to get a script from my development machine working on another Origin machine?
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 10/13/2006 : 08:03:46 AM
|
Origin/OriginPro makes no difference. When sharing your scripts it is important to avoid absolute paths (which are probably invalid on all but your PC). Other than that it's hard to give general rules. See the Sharing your Origin files chapter of the Origin Reference (Help > Origin) and the Programming Guide > Sharing Custom Applications chapter of the Programming Guide (Help > Programming).
Mike Buess Origin WebRing Member |
 |
|
psgst
UK
Posts |
Posted - 10/16/2006 : 06:59:20 AM
|
I've read through that stuff and tried it and it makes no difference. We usually just copy files between machines from a standard set of scripts, and never use absolute paths, they're always relative.
However, it doesn't appear that the MULTI worksheet template in [CreateGraph] script posted above is being loaded correctly.
Also, I've come across a new problem as I try and run the script on other machines. The part of the script in question is below:
[LoadData] // Open files and place them in new, seperate worksheets fdlog.path$ = "C:\MATLAB71\PIMS\"; // set fdlog's default path fdlog.ShowComment = 0; fdlog.UseGroup(Ascii); if (fdlog.MultiOpen() != 0/0); { loop (ii, 1, fdlog.MultiOpen.Count) { window -t data asciiImport; fdlog.Get(A, ii); open -w %A; %B = %H; window -r %B Sheet$(ii); } } // Merge all worksheets into one dataset fileCount = fdlog.MultiOpen.Count; if (fileCount == 0) { type -b "Error: No files have been selected for loading."; return; // exit the script } else if (fileCount > 10) { type -b "Error: Too many files selected. Maximum number is 10."; return; // exit the script } else { // copy col D from sheet represented by count to the column // represented by count in multiWks window -t data MULTI; %B = %H; window -r %B multiWks; %Z = ""; loop (jj, 1, fileCount) { // extraction of length data %(multiWks,jj) = Sheet$(jj)_D; // copy length data } }
(follow on post below)
|
 |
|
psgst
UK
Posts |
Posted - 10/16/2006 : 06:59:48 AM
|
As you can see I'm loading a number of Sheets (Sheet1, Sheet2, etc.) and then compiling them into multiWks. Now, multiWks gets created, but no Sheets get loaded. This script works on my dev machine, but not on other machines and I cannot see a reason why. Can anyone else see a problem in the code?
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 10/16/2006 : 08:16:50 AM
|
I don't know how many columns multiWks has but if fileCount is variable then sometimes multiWks won't have enough columns. Use if(filecount>wks.ncols) work -a (fileCount - wks.ncols) to create the necessary columns.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/16/2006 08:18:33 AM |
 |
|
psgst
UK
Posts |
Posted - 10/16/2006 : 09:09:42 AM
|
well, the idea is that no more than 10 sheets are imported, and multiWks has 10 sheets, so i guess a check will be necessary.
but for testing, all i'm doing is importing one sheet so it should only use one column in multiWks.
i'm guessing you can't see any problems that would prevent that in my script?
|
 |
|
psgst
UK
Posts |
Posted - 10/17/2006 : 05:15:32 AM
|
I inserted some type statements to try and debug the LoadData function and have come across a couple of irregularities. Here is the section of LoadData that appears to be failing, including debugging statements:
type "check files to open"; if (fdlog.MultiOpen() != 0/0); { type "YES files to open"; type "count = $(fdlog.MultiOpen.Count)"; loop (ii, 1, fdlog.MultiOpen.Count) { type "loop $(ii) new worksheet asciiImport"; window -t data asciiImport; type "loop $(ii) open fdlog GET"; fdlog.Get(A, ii); type "loop $(ii) open new worksheet"; open -w %A; type "loop $(ii) %B=%H"; %B = %H; type "loop $(ii) rename worksheet to Sheet$(ii)"; window -r %B Sheet$(ii); type "loop $(ii) end"; } type "end if"; } type "assigning count to fileCount"; // Merge all worksheets into one dataset fileCount = fdlog.MultiOpen.Count;
And here is the script output of those debugging statements:
check files to open YES files to open count = 1 assigning count to fileCount
Now from this I get the fact that the loop is not firing, yet I cannot see why. Running fdlog.MultiOpen.Count= in the script window I get the result FDLOG.MULTIOPEN.COUNT=1; which is right because I only selected to open one file. Also, after the for-loop is the debug statement "end if" to signal the end of the if-statement, however this never gets printed, even though it should whether the loop fires or not.
Does anyone have any feedback on this?
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 10/17/2006 : 06:45:09 AM
|
At this point I generally start looking for missing or extra semicolons ';' or braces. Turns out there is an errant semicolon at the end of the line if (fdlog.MultiOpen() != 0/0);
Mike Buess Origin WebRing Member |
 |
|
psgst
UK
Posts |
Posted - 10/17/2006 : 06:57:42 AM
|
Aye, I already tried that but the result is that processing stops at the line loop (ii, 1, fdlog.MultiOpen.Count) and the rest of the script fails to run. There has to be an explanation but I cannot see a visible one.
Its interesting to note that on my dev machine the presence of the semi-colon is irrelevant, yet on other machines the presence makes a difference to the processing one way or the other. I don't see how LabTalk can be so temperamental about a script that processes just fine on one machine, yet fails to process on another.
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 10/17/2006 : 07:36:01 AM
|
quote: I don't see how LabTalk can be so temperamental about a script that processes just fine on one machine, yet fails to process on another.
Nor do I. I've been sharing scripts for ten year and haven't encountered such a problem with a simple script like that. Only other advice I can suggest is to restart Origin on the offending machine. Possibly even reboot.
...Have you tried debugging in CodeBuilder?
...To confound things further, the script works perfectly on my PC.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/17/2006 11:09:18 AM
Edited by - Mike Buess on 10/17/2006 11:29:34 AM |
 |
|
psgst
UK
Posts |
Posted - 10/18/2006 : 06:04:05 AM
|
I've played a little with it in debugging in CodeBuilder but I need to read more into its features. I've passed the script, templates, and some sample data to Origin tech support for them to have a look at and see what they come back with.
Is there any kind of configuration options with Origin that might stop the script from working from machine to machine?
|
 |
|
Mike Buess
USA
3037 Posts |
|
psgst
UK
Posts |
Posted - 10/18/2006 : 09:21:08 AM
|
I got a reply from Origin tech just before you posted that Mike, with a very similar fix. Just an upgrade to SR6 has stamped out the problem I was seeing. Thanks for all your help, mate.
I'm still getting an issue loading in the MULTI.otw worksheet template but I'll review the code for that and see if I can find any problems.
|
 |
|
|
Topic  |
|