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
 symbol color, size...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ovince

Yugoslavia
Posts

Posted - 09/18/2006 :  02:39:20 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi All,

I am trying to place 40 Graphs to several Layouts. The Graphs are similar (with data points, binned means and binned medians). Plots are designated with different colors. When placing Graphs to Layouts the colors, sizes and other attributes can not be changed on Layout. I don'tknow what I am doing wrong so I would like to ask for help again. I am copy-pasting the program in whole (it is larger but easy to read)

void test4940(int Col, int Row)
{
int iOriGraphCount=Project.GraphPages.Count(); //Current number of graphs in project
printf("%i\n", iOriGraphCount);

int iLayersPerPage; //Number of layers per page
iLayersPerPage = Col * Row;

int iNewGraphCount;
iNewGraphCount = (iOriGraphCount - 1) / iLayersPerPage+1;
printf("%i\n", iNewGraphCount);

//Customize margins and gaps
int iLeft=10;
int iRight=10;
int iTop=10;
int iBottom=10;
int iHorizontalGap=5;
int iVerticalGap=5;

//Calculate the width and height for each layer
int iLayerWidth = (100-iLeft-iRight-iHorizontalGap)/Col;
int iLayerHeight = (100-iTop-iBottom-iVerticalGap)/Row;

int ii, jj, kk;
int iIndex=0;
for (ii=0; ii<iNewGraphCount; ii++)
{
GraphPage gpNew;
gpNew.Create("origin");

for (jj=0; jj<Row; jj++)
{
for (kk=0; kk<Col; kk++)
{
if (iIndex==iOriGraphCount) break;



if (jj!=0 || kk!=0) gpNew.AppendLayers("origin");
GraphLayer glNew=gpNew.Layers(jj*Col+kk);

//Format the layer
string strScript;
strScript.Format("layer.height=%d", iLayerHeight);
glNew.LT_execute(strScript);
strScript.Format("layer.width=%d", iLayerWidth);
glNew.LT_execute(strScript);
strScript.Format("layer.left=%d", iLeft+kk*(iLayerWidth+iHorizontalGap));
glNew.LT_execute(strScript);
strScript.Format("layer.top=%d", iTop+jj*(iLayerHeight+iVerticalGap));
glNew.LT_execute(strScript);
strScript.Format("lab -xb (T);");
glNew.LT_execute(strScript);
strScript.Format("lab -yl (index);");
glNew.LT_execute(strScript);
strScript.Format("lab -r Legend;");
glNew.LT_execute(strScript);

//Add dataplots to the new layer
GraphPage gpOld=Project.GraphPages(iIndex++);
string grpName;
grpName = gpOld.GetName();
printf("%s\n", grpName);


//strScript.Format("%P", grpName);
//glNew.LT_execute(strScript);
//LT_execute("type %P;");
//LT_execute("lab -p 45 2 -s %P;");
//strScript.Format("lab -p 45 2 -s %P;");
//glNew.LT_execute(strScript);
strScript.Format("lab -p 45 2 -s %s;", grpName);
glNew.LT_execute(strScript);

GraphLayer glOld=gpOld.Layers(0);
DataPlot dpAll=glOld.DataPlots(0);//crvAll
Curve ccAll(dpAll);

DataPlot dpMeanNoWeight=glOld.DataPlots(1);//crvMeanNoWeight
Curve ccMeanNoWeight(dpMeanNoWeight);

DataPlot dpMeanWeight=glOld.DataPlots(2);//crvMeanWeight
Curve ccMeanWeight(dpMeanWeight);

DataPlot dpMedian=glOld.DataPlots(3);//crvMedian
Curve ccMedian(dpMedian);

DataPlot dpErrMeanNoWeight=glOld.DataPlots(4);//ErrMeanNoWeight
Curve ccErrMeanNoWeight(dpErrMeanNoWeight);

DataPlot dpErrMeanWeight=glOld.DataPlots(5);//ErrMeanWeight
Curve ccErrMeanWeight(dpErrMeanWeight);


glNew.AddPlot(ccAll, IDM_PLOT_SCATTER);
dpAll.Curve.Symbol.Shape.nVal = 2;
dpAll.Curve.Symbol.Size.nVal = 3;
dpAll.Curve.Symbol.EdgeColor.nVal = 2;

glNew.AddPlot(ccMeanNoWeight, IDM_PLOT_LINESYMB);
dpMeanNoWeight.Curve.Symbol.Shape.nVal = 2;
dpMeanNoWeight.Curve.Symbol.Size.nVal = 3;
dpMeanNoWeight.Curve.Symbol.EdgeColor.nVal = 2;
dpMeanNoWeight.Curve.Line.Color.nVal = 2;

glNew.AddPlot(ccMeanWeight, IDM_PLOT_LINESYMB);
dpMeanWeight.Curve.Symbol.Shape.nVal = 2;
dpMeanWeight.Curve.Symbol.Size.nVal = 3;
dpMeanWeight.Curve.Symbol.EdgeColor.nVal = 3;
dpMeanWeight.Curve.Line.Color.nVal = 3;

glNew.AddPlot(ccMedian, IDM_PLOT_LINESYMB);
dpMedian.Curve.Symbol.Shape.nVal = 2;
dpMedian.Curve.Symbol.Size.nVal = 3;
dpMedian.Curve.Symbol.EdgeColor.nVal = 4;
dpMedian.Curve.Line.Color.nVal = 4;

glNew.AddPlot(ccErrMeanNoWeight, IDM_PLOT_LINESYMB);

glNew.AddPlot(ccErrMeanWeight, IDM_PLOT_LINESYMB);

glNew.Rescale();

}
}
}
}


Why the colors, sizes and other features are not changed?

Thank you
Oliver

Deanna

China
Posts

Posted - 09/18/2006 :  05:41:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Oliver, your code is changing the shapes, color, size of the data plots on the old graph pages instead of those on the new graph page. I wonder whether you want to change the plots on old graph pages or those on the new one.

If the old plots are to be changed, your current code is fine, but you have better add the following line:

gpOld.Refresh(true); //Refresh the graph page


If the plots on the new graph page are to be changed, please get the data plot on the new layer before you change the formats.

The following code examplifies how to change the old data plots as well as the new data plots. I hope it will be helpful.

void test5120()
{
GraphLayer glOld=Project.ActiveLayer();
if (! glOld.IsValid() ) return;

GraphPage gpOld=glOld.GetPage();

DataPlot dpOld=glOld.DataPlots(0);
if (! dpOld.IsValid() ) return;

//Change the old data plot
dpOld.Curve.Symbol.Shape.nVal = 2;
dpOld.Curve.Symbol.Size.nVal = 3;
dpOld.Curve.Symbol.EdgeColor.nVal = 2;

//Refresh the old graph page
gpOld.Refresh(true);

Curve ccOld(dpOld);

GraphPage gpNew;
gpNew.Create("origin");

GraphLayer glNew=gpNew.Layers(0);
glNew.AddPlot(ccOld, IDM_PLOT_SCATTER);

DataPlot dpNew=glNew.DataPlots(0);
if (! dpNew.IsValid() ) return;

//Change the new data plot
dpNew.Curve.Symbol.Shape.nVal = 3;

//Rescale and refresh
glNew.Rescale();

}


Deanna
OriginLab GZ Office
Go to Top of Page

ovince

Yugoslavia
Posts

Posted - 09/19/2006 :  06:52:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi

Thank you Deanna for help. It works works but steel some proplem occure when running program. Namely, although the individual plots that are read in by program are correct, when making a graph layer something happens and some graphs (not all) are plotted uncorrectly. Why I don not know. I will copy paste the program again in whole and will ask you again what I am doing wrong. I hope I am not asking to much and really thanks again.

void test55555(int Col, int Row)
{
int iOriGraphCount=Project.GraphPages.Count(); //Current number of graphs in project
printf("%i\n", iOriGraphCount);

int iLayersPerPage; //Number of layers per page
iLayersPerPage = Col * Row;

//if (iLayersPerPage<iOriGraphCount)
//{
// printf("Not enough layers to arrange the graphs");
// return;
//}

int iNewGraphCount;
iNewGraphCount = (iOriGraphCount - 1) / iLayersPerPage+1;
printf("%i\n", iNewGraphCount);

//Customize margins and gaps
int iLeft=10;
int iRight=10;
int iTop=10;
int iBottom=10;
int iHorizontalGap=5;
int iVerticalGap=5;

//Calculate the width and height for each layer
int iLayerWidth = (100-iLeft-iRight-iHorizontalGap)/Col;
int iLayerHeight = (100-iTop-iBottom-iVerticalGap)/Row;

int ii, jj, kk;
int iIndex=0;
for (ii=0; ii<iNewGraphCount; ii++)
{
GraphPage gpNew;
gpNew.Create("origin");
//Sleep(10000);

for (jj=0; jj<Row; jj++)
{
for (kk=0; kk<Col; kk++)
{
if (iIndex==iOriGraphCount) break;



if (jj!=0 || kk!=0) gpNew.AppendLayers("origin");
GraphLayer glNew=gpNew.Layers(jj*Col+kk);

//Format the layer
string strScript;
strScript.Format("layer.height=%d", iLayerHeight);
glNew.LT_execute(strScript);
strScript.Format("layer.width=%d", iLayerWidth);
glNew.LT_execute(strScript);
strScript.Format("layer.left=%d", iLeft+kk*(iLayerWidth+iHorizontalGap));
glNew.LT_execute(strScript);
strScript.Format("layer.top=%d", iTop+jj*(iLayerHeight+iVerticalGap));
glNew.LT_execute(strScript);
strScript.Format("lab -xb (T);");
glNew.LT_execute(strScript);
strScript.Format("lab -yl (index);");
glNew.LT_execute(strScript);
//strScript.Format("lab -r Legend;");
//glNew.LT_execute(strScript);


//Add dataplots to the new layer
GraphPage gpOld=Project.GraphPages(iIndex++);

// arrange name
string grpName = gpOld.GetName();
strScript.Format("lab -p 45 2 -s %s;", grpName);
glNew.LT_execute(strScript);


//Refresh the old graph page
//gpOld.Refresh(true);

// create graph Layer
GraphLayer glOld=gpOld.Layers(0);

// add and format plots
DataPlot dpOldAll=glOld.DataPlots(0);//crvAll
Curve ccAll(dpOldAll);

glNew.AddPlot(ccAll, IDM_PLOT_SCATTER);
DataPlot dpNewAll=glNew.DataPlots(0);
if (! dpNewAll.IsValid() ) return;
//Change the new data plot
dpNewAll.Curve.Symbol.Shape.nVal = 2;
dpNewAll.Curve.Symbol.Size.nVal = 4;
dpNewAll.Curve.Symbol.EdgeColor.nVal = 1;


DataPlot dpOldMeanNoWeight=glOld.DataPlots(1);//crvMeanNoWeight
Curve ccMeanNoWeight(dpOldMeanNoWeight);

glNew.AddPlot(ccMeanNoWeight, IDM_PLOT_LINESYMB);
DataPlot dpNewMeanNoWeight=glNew.DataPlots(1);
if (! dpNewMeanNoWeight.IsValid() ) return;
//Change the new data plot
dpNewMeanNoWeight.Curve.Symbol.Shape.nVal = 2;
dpNewMeanNoWeight.Curve.Symbol.Size.nVal = 6;
dpNewMeanNoWeight.Curve.Symbol.EdgeColor.nVal = 2;
dpNewMeanNoWeight.Curve.Line.Color.nVal = 2;


DataPlot dpOldMeanWeight=glOld.DataPlots(2);//crvMeanWeight
Curve ccMeanWeight(dpOldMeanWeight);

glNew.AddPlot(ccMeanWeight, IDM_PLOT_LINESYMB);
DataPlot dpNewMeanWeight=glNew.DataPlots(2);
if (! dpNewMeanWeight.IsValid() ) return;
//Change the new data plot
dpNewMeanWeight.Curve.Symbol.Shape.nVal = 2;
dpNewMeanWeight.Curve.Symbol.Size.nVal = 6;
dpNewMeanWeight.Curve.Symbol.EdgeColor.nVal = 3;
dpNewMeanWeight.Curve.Line.Color.nVal = 3;



DataPlot dpOldMedian=glOld.DataPlots(3);//crvMedian
Curve ccMedian(dpOldMedian);
glNew.AddPlot(ccMedian, IDM_PLOT_LINESYMB);
DataPlot dpNewMedian=glNew.DataPlots(3);
if (! dpNewMedian.IsValid() ) return;
dpNewMedian.Curve.Symbol.Shape.nVal = 2;
dpNewMedian.Curve.Symbol.Size.nVal = 6;
dpNewMedian.Curve.Symbol.EdgeColor.nVal = 8;
dpNewMedian.Curve.Line.Color.nVal = 8;


DataPlot dpErrMeanNoWeight=glOld.DataPlots(4);//ErrMeanNoWeight
Curve ccErrMeanNoWeight(dpErrMeanNoWeight);
glNew.AddPlot(ccErrMeanNoWeight, IDM_PLOT_LINESYMB);

DataPlot dpErrMeanWeight=glOld.DataPlots(5);//ErrMeanWeight
Curve ccErrMeanWeight(dpErrMeanWeight);
glNew.AddPlot(ccErrMeanWeight, IDM_PLOT_LINESYMB);


LT_execute("legend.text$='\l(1) all poins
\l(2) mean-no weight
\l(3) mean-weight
\l(4) median';");
LT_execute("legend.x = 9;");
LT_execute("legend.y = 0.9;");
//LT_execute("legend.left=4500;");
//LT_execute("legend.top=3100;");
LT_execute("legend.background = 1;");

glNew.Rescale();


}
}
}
}

oliver
Go to Top of Page

Deanna

China
Posts

Posted - 09/19/2006 :  10:10:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Oliver, your code looks fine. I tried it on some graphs I made, but I did not spot any problem.

Please make sure the first layer of each graph page has at least four data plots.

If you don't mind, please send us your opj file via tech@originlab.com. It will help us in better locating the problem.

Deanna
OriginLab GZ Office
Go to Top of Page

ovince

Yugoslavia
Posts

Posted - 09/20/2006 :  12:06:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
dear deanna,

Thank you in advance for helping around this. I have sent you an email with 'for deanna' subject.

Oliver
Go to Top of Page

Deanna

China
Posts

Posted - 09/21/2006 :  03:35:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Got your mail! Thanks.



Deanna
OriginLab GZ Office
Go to Top of Page

ovince

Yugoslavia
Posts

Posted - 09/21/2006 :  3:05:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thank,

I have replyed to email
oliver
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