### Aptech Systems, Inc. Worldwide Headquarters

Address:

Aptech Systems, Inc.

2350 East Germann Road, Suite #21

Chandler, AZ 85286Phone: 360.886.7100

FAX: 360.886.8922**Ready to Get Started?**### Request Quote & Product Information

### Industry Solutions

### Products

### Resources

### Support

### Training & Events

Want more guidance while learning about the full functionality of GAUSS and its capabilities? Get in touch for in-person training or browse additional references below.

### Tutorials

Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.

### Have a Specific Question?

### Q&A: Register and Login

### Support Plans

Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.

### User Forums

Join our community to see why our users are considered some of the most active and helpful in the industry!

### Where to Buy

Available across the globe, you can have access to GAUSS no matter where you are.

### Recent Tags

applications character vectors CML CMLMT Constrained Optimization datasets dates dlibrary dllcall error error handling errors Excel file i/o floating network GAUSS Engine graphics GUI hotkeys installation Java API license licensing linux loading data loops matrices matrix matrix manipulation Maxlik MaxLikMT Memory optimization Optmum output PQG graphics procs RAM random numbers string functions strings structures threading Time Series writing data### Recent Questions

### Features

### Time Series 2.0 MT

### Industry Solutions

### Find out more now

### Time Series MT 2.1

# Resources

# how to make single legend for the overlapping graphs

I am trying to combine two graphs into one (transparently) because the x-axis of the two graphs do not exactly match. If I draw a graph using below command I can have the graph that I want but the legend boxes are separate. I was wondering if it is possible to make the two legend boxes into one (or at least if I can get rid of the box frame around the legend). Thank you so much!

begwind;

window(1,1,1);

ylabel("Empirical Rejection Rate");

xlabel("b");

ytics(0,0.3,0.05,0.5);

xtics(0,1,0.05,0.5);

_pdate=0;

_plctrl = { 4,4,0 };

_pltype = { 6, 3, 4 };

_pstype = { 10, 8, 0 };

_plwidth= {11,11, 10};

_pcolor= {0,0,0};

_psymsiz={1.5,1.5};

_plegstr=

"AM_N(0,1)00

BM_N(0,1)00

0.05";

_plegctl= { 2, 5, 1.5, 4 };

strl_1=ftocv(p[1],1,1);

strl_2=ftocv(tt[1],2,0);

str_r=ftocv(r1[1],1,0);

fonts("simplex simgrma");

string_title=" Non-random Bernoulli, Bartlett, p="$+strl_1 $+ " \202r\201=" $+ str_r $+ " T=" $+ strl_2;

title(string_title);

strl_1=ftocv(p[1]*10,1,0);

strl_2=ftocv(tt[1],2,0);

str_r=ftocv(r1[1]*10,1,0);

prt_title="-cf=" $+ "fixed_p_"$+strl_1 $+ "_r_" $+ str_r $+ "_T_" $+ strl_2 $+ ".eps" $+" -c=1 -q";

//graphprt(prt_title);

setwind(1);

xy(x1,y1);

ytics(0,0.3,0.05,0.5);

xtics(0,1,0.05,0.5);

_pdate = ""; //not print date

_plctrl = { 1};

_pltype = { 6};

_pstype = { 5 };

_plwidth= {11};

_pcolor= {0};

_psymsiz={2};

_plegctl= { 2, 4, 1.7, 3};

_plegstr=

"ES_N(0,1)";

setwind(1);

xy(x_es,y1_es);

endwind;

## 3 Answers

I think it will be simpler in many ways to draw just 1 graph. If the x's for the different y's have the same number of elements, you can just horizontally concatenate them and draw the overlapping graph, for example:

x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; y1 = cos(x); y2 = sin(x); //horizontally concatenate y's y_final = y1~y2; xy(x, y_final);

Since you cannot concatenate matrices or vectors with incompatible dimensions, if the y's have a different number of elements you will have to pad the shorter one with missing values. For example:

x1 = seqa(1,1,100); x2 = seqa(1,1,10); y1 = cos(x1); y2 = sin(x2); //create a 90x1 vector of missing values pad = miss(zeros(90,1), 0); //vertically concatenate the missing values on top of 'y2' y2 = pad|y2; //horizontally concatenate 'y1' and 'y2' y_final = y1~y2; xy(x1, y_final);

Thank you so much for the quick answer. I followed the way you suggested. My x1 and x2 do not have much in common other than that all the numbers for both x1 and x2 lie between 0 and 1. When I draw the graph by padding with the missing values, the xy() gave me discontinuous lines(curves). It seems that the curve ends when a missing value is encountered and a new curve begins plotting at the next non-missing value. I was wondering if there is anyway to connect these discontinuous curves smoothly. Thank you.

Yes, the line will be broken up by missing values. For a continuous curve, keep your data points contiguous. You can ensure this by vertically concatenating the vector of missing values that you are using for padding on top (or on bottom, either will work) of your data. Take a look at the second code snippet in the first response to see an example of this.