# Putting a legend inside the graph without a replication

Hi All,

I have a question regarding how to set-up a legend inside the graph without replications. Assume that we have the same type of lines (see the following example). How we can put the labels in the legend for them without a replication? To explain it further, I have two 3's, two 4's, two 1's, and two 2's in:

_pltype = {6,3,4,1,2,3,4,1,2};

as each number represents the lower bound and upper bound of an estimated function. I would only like to assign one label such as TFBM (with N[-1/3]) to the number 2 as an example; see _plegstr in the code below, but I do not know how to do it. In the current formating that I put here, an extra line shows up in the legend without a label.

I appreciate any suggestions!

graphset;
_plegstr = " f(x)\000 FBM \000 TFBM (with N[-1/3])\000 TFBM (with N[-1/4])\000 TFBM (with N[-1/5])\000 TFBM (with N[-1/6]) " ;
xlabel("TFBM");
_pcolor = {1,1,1,1,1,1,1,1,1};
_pltype = {6,3,4,1,2,3,4,1,2};
_plwidth = {15,15,15,15,15,15,15,15,15};
_pnum = 2;
_pnumht = 0.21;
_paxht = 0.21;
_pypmax = 2;
_pxpmax = 2;
xtics(-1,1,1,1);
xy(xf, yff~CI_upmean_temp4d0~CI_upmean_temp4d01~CI_upmean_temp4d03~CI_upmean_temp4d04
~CI_lowmean_temp4d0~CI_lowmean_temp4d01~CI_lowmean_temp4d03~CI_lowmean_temp4d04);

0

I would not use the old PQG graphics. With the newer GAUSS graphics, you can make a legend entry not show up by setting an empty string for that entry. Here is an example graph:

The code to create the graph is below. Not all of the settings included in the code are necessary, but I thought it might be helpful for you to see these options:

new;

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

// Set the size of the graph
plotCanvasSize("px", 600 | 400);

/*
** Legend settings
*/

// Use LaTeX in the legend string
plotSetTextInterpreter(&myPlot, "LaTeX", "legend");

// The final three empty strings will not
// show up on the legend
leg_str = "f(x)" $| "\\text{FBM}"$|
"\\text{TFBM (with } N^{-1/3})" $| "\\text{TFBM (with } N^{-1/4})"$|
"\\text{TFBM (with } N^{-1/5})" $| "\\text{TFBM (with } N^{-1/6})"$|
"" $| ""$|
"";
// Set the legend strings and place the top left
// of the legend bounding box at x=-0.35, y=0.25
plotSetLegend(&myPlot, leg_str, -1 | 3.35, 1);

plotSetLegendFont(&myPlot, "arial", 14);

// Make legend box transparent
plotSetLegendBkd(&myPlot, 0);

/*
** Other graph settings
*/

plotSetXLabel(&myplot, "TFBM");

// Get 5 colors from the 'set2' color palette
clrs = getColorPalette("set2", 5);

// Re-arrange the colors so the upper and lower
// bounds match colors
clrs = clrs[1 2 3 4 5 2 3 4 5];
plotSetLineColor(&myPlot, clrs);

plotSetLineStyle(&myPlot, 1 | 2 | 3 | 4 | 5 |2 |3 | 4 | 5 );

// Place the first X tick label at -1 and draw
// an additional tick every 1 unit
plotSetXTicInterval(&myPlot, 1, -1);

// Place the first Y tick label at 0 and draw
// an additional tick every 1 unit
plotSetYTicInterval(&myPlot, 1, 0);

plotSetYrange(&myPlot, 0, 3.3);

plotSetTicLabelFont(&myPlot, "arial", 14);

/*
** Create data to plot and draw plot
*/
xf = seqa(-1, 0.01, 201);
scl = { 0, 2, 3, 4, 5, 2, 3, 4, 5 };
yf = abs(cos(xf .* 0.2 .*scl')) .* seqa(0.01, 0.1, 9)' + scl';
yf = yf./3 - 1 + seqa(0.01, 0.005, rows(yf));
yf = yf.^2;

plotXY(myPlot, xf, yf);

0

Thank you for the response. But I would like to follow the old-style because of some requirements. Are there any ways to do it in the old style?

0

What are your requirements?

0

It is a Journal requirement. The shapes of graphs fit the old style more rather than the new one [or at least I do not know how to do it with the new style]. Here are some requirements:

[1] There should be a full-frame around the graph.

[2] The legend would be inside the graph with a full-frame around it.

[3] No colors for the lines; black or dark blue is acceptable

[4] There should be both xtics and ytics all around the frame towards inside of the frame, but only the left one and down one need to have numbers.

Thanks in advance for any further suggestions.

### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.

### Try GAUSS for 14 days for FREE

See what GAUSS can do for your data