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
 Origin Forum
 set the color and style of several curves...?

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
hancok Posted - 04/28/2005 : 06:27:55 AM
Origin Version: v7.03
Operating System: windows XP

Hi,
I am try to program a button that I placed in a graph window.
The graph window contains 12 layers (to make 12 graphs on the same page) and each layer will contain 4 curves (after importation). I would like to have different color (red or blue) and style (solid or dot) for these 4 curves.
Each curve is one Ascii file. So I use "import mulpile" function.
here is what I made:

--------------------------------------
fdlog.ShowComment = 0;
fdlog.UseGroup(Ascii);

if (fdlog.MultiOpen() != 0/0)
{
loop (ii, 1, fdlog.MultiOpen.Count)
{
win -t data Origin;
FDlog.Get(A, ii);
open -w %A;

for (i=1;i<=12;i++) //"i" represents the nb of layer in the graph
{
window -a graph1;
layer -s $(i); //Active the layer one by one

for (j=1;j<=4;j++) //"j" represents the nb of curves I import in 1 layer.
{
layer -i Data$(i)C$(j)_B;

if (j=1) {set Data$(i)C$(j)_B -c 2
set Data$(i)C$(j)_B -d 0};// 1st curve: red + solid line
else
{ if (j=2) {set Data$(i)C$(j)_B -c 2
set Data$(i)C$(j)_B -d 2};//2nd curve: red + dot line
};
else
{ if (j=3) {set Data$(i)C$(j)_B -c 4
set Data$(i)C$(j)_B -d 0};//3rd curve: blue + solid line
};
else
{ if (j=4) {set Data$(i)C$(j)_B -c 4
set Data$(i)C$(j)_B -d 2};//4th curve: blue + dot line
};

rescale;
}; // end first loop for

}; // end second loop for
}
}
window -a graph1;

----------------------------------

However it doesn't work as I wish....it plots the 4 curves I ask for in each of the 12 layers (that is correct) but they are all solid and black line. I don't manage to get blue or red or dot line...

thanks a lot for your help.

9   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 04/29/2005 : 06:44:02 AM
Put your entire script in ImportFile.ogs like you had said in your next to last post, i.e.,...

[Main]
// Main code

[RunSwitch]
// Switch code

Call it from the script window with run.section(ImportFile.ogs,Main) or run from a button by making the button settings look like this...

File: ImportFile.ogs
Section: Main
Context: Always
Other settings are irrelavent

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 04/29/2005 06:47:54 AM
hancok Posted - 04/29/2005 : 04:24:06 AM
ok I found out...
I just put the part:

[RunSwitch]
Switch(j)
{
...
...
}


in a script window that I saved as ImportFile.ogs
Then I call it as run.section(ImportFile.ogs,RunSwitch) and it works fine now.
thanks again.
hancok Posted - 04/29/2005 : 04:03:57 AM
Hi,

Here is my program now:

[Main]
fdlog.ShowComment = 0;
fdlog.UseGroup(Ascii);

if (fdlog.MultiOpen() != 0/0)
{
loop (ii, 1, fdlog.MultiOpen.Count)
{
win -t data Origin;
FDlog.Get(A, ii);
open -w %A;
} //end loop
} //end if

for (i=1;i<=12;i++)
{
window -a graph1;
layer -s $(i);
for (j=1;j<=4;j++)
{
layer -i data$(i)C$(j)_B;
run.section(,RunSwitch);
}; // end first loop for
}; // end second loop for
window -a graph1;

[RunSwitch]
switch(j)
{
case 1:
set data$(i)C$(j)_B -c 2;
set data$(i)C$(j)_B -d 0;
break;
case 2:
set data$(i)C$(j)_B -c 2;
set data$(i)C$(j)_B -d 2;
break;
case 3:
set data$(i)C$(j)_B -c 4;
set data$(i)C$(j)_B -d 0;
break;
case 4:
set data$(i)C$(j)_B -c 4;
set data$(i)C$(j)_B -d 2;
break;
}
-------------------------

You said I should save the all script in a OGS file so I opened the script window, pasted the script as written above and save as ImportFile.OGS.
However I don't manage to execute the code now...I created a button and put in the script part ImportFile but nothing happen when I click on the button so I guess that's not the right way to executate the code which is in the ImportFile.OGS file...
thanks for your help.
Mike Buess Posted - 04/28/2005 : 10:22:17 AM
The break statement in the switch command might also be breaking the for loop which contains it. There are two possible solutions...

1) Replace the switch command with the four consecutive if statements I suggested at the bottom of my last post. (This is easiest.)

2) Place the switch statement in a separate program section. (This is possible only if your script is in an OGS file.)

[Main]
fdlog.ShowComment = 0;
fdlog.UseGroup(Ascii);

if (fdlog.MultiOpen() != 0/0)
{
loop (ii, 1, fdlog.MultiOpen.Count)
{
win -t data Origin;
FDlog.Get(A, ii);
open -w %A;

for (i=1;i<=12;i++)
{
window -a graph1;
layer -s $(i);

for (j=1;j<=4;j++)
{
layer -i Data$(i)C$(j)_B;
run.section(,RunSwitch);
}; // end first loop for
}; // end second loop for

} //end loop
} //end if
window -a graph1;

[RunSwitch]
switch( j )
{
case 1:
set Data$(i)C$(j)_B -c 2;
set Data$(i)C$(j)_B -d 0;
break;
case 2:
set Data$(i)C$(j)_B -c 2;
set Data$(i)C$(j)_B -d 2;
break;
case 3:
set Data$(i)C$(j)_B -c 4;
set Data$(i)C$(j)_B -d 0;
break;
case 4:
set Data$(i)C$(j)_B -c 4;
set Data$(i)C$(j)_B -d 2;
break;
}

Mike Buess
Origin WebRing Member
hancok Posted - 04/28/2005 : 10:14:05 AM
ok I think I found the pb.. it was the:
} //end loop
} //end if

which was not at the right place...I hope it will be ok now.
Thanks for the help!
hancok Posted - 04/28/2005 : 09:47:36 AM
Thanks for the tip !
However it seems there is still something wrong: when I click on the button to start the program it just plot the first curve even if I select 4 files when importing files...It seems it stops after the first loop (j=1) in the second loop for.

Do you see something strange in the code which could explain why it is stopping after the 1st loop?

-----------------------------------------------
fdlog.ShowComment = 0;
fdlog.UseGroup(Ascii);

if (fdlog.MultiOpen() != 0/0)
{
loop (ii, 1, fdlog.MultiOpen.Count)
{
win -t data Origin;
FDlog.Get(A, ii);
open -w %A;

for (i=1;i<=12;i++)
{
window -a graph1;
layer -s $(i);

for (j=1;j<=4;j++)
{
layer -i Data$(i)C$(j)_B;
switch( j )
{
case 1:
set Data$(i)C$(j)_B -c 2;
set Data$(i)C$(j)_B -d 0;
break;
case 2:
set Data$(i)C$(j)_B -c 2;
set Data$(i)C$(j)_B -d 2;
break;
case 3:
set Data$(i)C$(j)_B -c 4;
set Data$(i)C$(j)_B -d 0;
break;
case 4:
set Data$(i)C$(j)_B -c 4;
set Data$(i)C$(j)_B -d 2;
break;
}

}; // end first loop for
}; // end second loop for

} //end loop
} //end if
window -a graph1;
----------------------------------
Mike Buess Posted - 04/28/2005 : 09:11:51 AM
I think you're only allowed one 'else' per 'if'. Try switch instead...

switch( j )
{
case 1:
set Data$(i)C$(j)_B -c 2;
set Data$(i)C$(j)_B -d 0;
break;
case 2:
set Data$(i)C$(j)_B -c 2;
set Data$(i)C$(j)_B -d 2;
break;
case 3:
set Data$(i)C$(j)_B -c 4;
set Data$(i)C$(j)_B -d 0;
break;
case 4:
set Data$(i)C$(j)_B -c 4;
set Data$(i)C$(j)_B -d 2;
break;
}

...Also your 'if' conditions were incorrect in your original post. Should be if( j==1 ) not if( j=1 ). So this should also work (else statements are not necessary)...

if( j==1 ) {
set Data$(i)C$(j)_B -c 2;
set Data$(i)C$(j)_B -d 0;
};
if( j==2 ) {
set Data$(i)C$(j)_B -c 2;
set Data$(i)C$(j)_B -d 2;
};
if( j==3 ) {
set Data$(i)C$(j)_B -c 4;
set Data$(i)C$(j)_B -d 0;
};
if( j==4 ) {
set Data$(i)C$(j)_B -c 4;
set Data$(i)C$(j)_B -d 2;
};

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 04/28/2005 09:25:38 AM
hancok Posted - 04/28/2005 : 09:01:07 AM
Yes.. I have seen that afterward I send the message...I added the missing semicolons (as showed lower) but it is still not giving me dot line or color line...

Is it correct to write like this:

If (condition1) {expression1;expression2;}
else
{
if (condition2) {expression3;expression4;}
};
else
{
if (condition3) {expression5;expression6;}
};
else
{
if (condition4) {expression7;expression8;}
};

because it is actually what I am doing...
Mike Buess Posted - 04/28/2005 : 08:24:54 AM
Several semicolons are missing. For example,

if (j=1) {set Data$(i)C$(j)_B -c 2; // this semicolon was missing
set Data$(i)C$(j)_B -d 0};// 1st curve: red + solid line
else
{ if (j=2) {set Data$(i)C$(j)_B -c 2; // this semicolon was missing
set Data$(i)C$(j)_B -d 2};//2nd curve: red + dot line
};

You code will probably work once you insert all necessary semicolons.

Mike Buess
Origin WebRing Member

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