Making a graph

Hi there,

I wish to create a graph, but it does not work on Gauss 19. This is the code:

y=tvec~avec1;
x=timevec1~timevec1;

_pmcolor={0,0,0,0,0,0,0,0,15};
_pbox = 15;
_pdate = "";
_plctrl = {0, 0, 0, 0 };
_pstype = {0, 0, 0};
_pcolor = {0,0,0};
_plwidth={4,4,3,4};
_pltype={3,6};
liner1=1~2~20~50000~80~50000~1~1~1;
liner2=1~2~20~100000~80~100000~1~1~1;
liner3=1~2~20~150000~80~150000~1~1~1;
liner4=1~2~20~200000~80~200000~1~1~1;
liner5=1~2~20~250000~80~250000~1~1~1;
_pline=liner1|liner2|liner3|liner4|liner5;

ylabel("Variable");
xlabel("Time");
title ("Total Variable");

x0=30|74;
y1=0|300000;
scale(x0,y1);

_plegstr = "current level \000adjusted level";
_plegctl = {2,8,4,1};

graphprt("-c=1 -cf=fig1.eps" );

I suspicious that I am using a older version code to create graphs, but even in that case, how can I adapt it for newer versions?

Thanks!

6 Answers



0



accepted

You are correct that this is old code and that it should be updated. I'm happy to help you with that. Can you tell me what the dates in timvec1 look like? Are they integer years? Or do they have quarters in the form of 1995.0 1995.25 1995.50 1995.75 1996.0?

aptech

1,773


0



thank you!

"timvec1" are years, so they're integer ones.



0



Any help is welcome, please.



0



You should still be able to run the old style graph, but your code is missing the call to the xy function.

However, below is some updated code to create the graph. You will have to define x and y first.

struct plotControl myPlot;
myPlot = plotGetDefaults("xy");

plotCanvasSize("px", 600 | 400);

plotSetYlabel(&myPlot, "Variable", "arial", 14);
plotSetXlabel(&myPlot, "Time");
plotSetTitle(&myPlot, "Total Variable","arial", 14);

plotSetXTicInterval(&myPlot, 5, 30);
plotSetYRange(&myPlot, 0, 300000);
plotSetYTicLabel(&myPlot, "%.2g");

leg_text = "current level" $| "adjusted level" $| reshape("", 5,1);
plotSetLegend(&myPlot, leg_text, 48 | 70000);
plotSetLegendBkd(&myPlot, 1);

clrs = reshape("black", 2, 1) $| reshape("midnight-blue", 5, 1);
plotSetLineColor(&myPlot, clrs);
plotSetLineStyle(&myPlot, 1 | 2 | reshape(3,5,1));

plotXY(myPlot, x, y;

lines = { 50000 100000 150000 200000 250000,
           50000 100000 150000 200000 250000 };

plotAddXY(30 | 75, lines

aptech

1,773


0



Thank you! it worked pretty well. I just would like know how to change the y-axis number format, because it has format like "4.5e+16".

 



0



Comment out the line:

plotSetYTicLabel(&myPlot, "%.2g");

and see if you like that better.

aptech

1,773

Your Answer

6 Answers

0
accepted

You are correct that this is old code and that it should be updated. I'm happy to help you with that. Can you tell me what the dates in timvec1 look like? Are they integer years? Or do they have quarters in the form of 1995.0 1995.25 1995.50 1995.75 1996.0?

0

thank you!

"timvec1" are years, so they're integer ones.

0

Any help is welcome, please.

0

You should still be able to run the old style graph, but your code is missing the call to the xy function.

However, below is some updated code to create the graph. You will have to define x and y first.

struct plotControl myPlot;
myPlot = plotGetDefaults("xy");

plotCanvasSize("px", 600 | 400);

plotSetYlabel(&myPlot, "Variable", "arial", 14);
plotSetXlabel(&myPlot, "Time");
plotSetTitle(&myPlot, "Total Variable","arial", 14);

plotSetXTicInterval(&myPlot, 5, 30);
plotSetYRange(&myPlot, 0, 300000);
plotSetYTicLabel(&myPlot, "%.2g");

leg_text = "current level" $| "adjusted level" $| reshape("", 5,1);
plotSetLegend(&myPlot, leg_text, 48 | 70000);
plotSetLegendBkd(&myPlot, 1);

clrs = reshape("black", 2, 1) $| reshape("midnight-blue", 5, 1);
plotSetLineColor(&myPlot, clrs);
plotSetLineStyle(&myPlot, 1 | 2 | reshape(3,5,1));

plotXY(myPlot, x, y;

lines = { 50000 100000 150000 200000 250000,
           50000 100000 150000 200000 250000 };

plotAddXY(30 | 75, lines

0

Thank you! it worked pretty well. I just would like know how to change the y-axis number format, because it has format like "4.5e+16".

 

0

Comment out the line:

plotSetYTicLabel(&myPlot, "%.2g");

and see if you like that better.


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.