I have a series of graphs combined by means of -twoway-, and I would like to obtain just one legend in common at the end.
Here the data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte origin float pr byte dest float lab 1 -.0020876 1 1 2 -.1106231 1 2 3 -.1982656 1 3 4 -.254306 1 4 1 -.026527 2 5 2 .1525901 2 6 3 -.08564 2 7 4 -.0716028 2 8 1 .0419532 3 9 2 -.006786 3 10 end label values origin origin label def origin 1 `""Ser/""WhC""', modify label def origin 2 "PB", modify label def origin 3 `""St.""WC""', modify label def origin 4 `""Unst.""WC""', modify label values dest dest label def dest 1 "DEST: Ser/WhC", modify label def dest 2 "DEST: PB", modify label def dest 3 "DEST: St WC", modify label values lab lab label def lab 1 ".00", modify label def lab 2 "-.11***", modify label def lab 3 "-.20***", modify label def lab 4 "-.25***", modify label def lab 5 "-.03***", modify label def lab 6 ".15***", modify label def lab 7 "-.09***", modify label def lab 8 "-.07***", modify label def lab 9 ".04***", modify label def lab 10 "-.01", modify
Code:
tw(bar pr origin if lab == 1, ) (scatter pr origin if lab == 1, mlabel(lab) mlabangle(45) mlabposition(12) mlabgap(6) mlabsize(vsmall) msymbol(i)) /// (bar pr origin if lab == 2, ) (scatter pr origin if lab == 2, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 3, ) (scatter pr origin if lab == 3, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 4, ) (scatter pr origin if lab == 4, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i)) /// (bar pr origin if lab == 5, ) (scatter pr origin if lab == 5, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 6, ) (scatter pr origin if lab == 6, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i)) /// (bar pr origin if lab == 7, ) (scatter pr origin if lab == 7, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i)) /// (bar pr origin if lab == 8, ) (scatter pr origin if lab == 8, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 9, ) (scatter pr origin if lab == 9, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 10, ) (scatter pr origin if lab == 10, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 11, ) (scatter pr origin if lab == 11, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 12, ) (scatter pr origin if lab == 12, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i)) /// (bar pr origin if lab == 13, ) (scatter pr origin if lab == 13, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 14, ) (scatter pr origin if lab == 14, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 15, ) (scatter pr origin if lab == 15, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 16, ) (scatter pr origin if lab == 16, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i)) /// (bar pr origin if lab == 17, ) (scatter pr origin if lab == 17, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 18, ) (scatter pr origin if lab == 18, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// (bar pr origin if lab == 19, ) (scatter pr origin if lab == 19, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i)) /// (bar pr origin if lab == 20, ) (scatter pr origin if lab == 20, mlabel(lab) mlabangle(45) mlabposition(6) mlabgap(3) mlabsize(vsmall) msymbol(i) ) /// , by(dest, col(5)) /// scheme(s1mono) /// xlabel(1(1)4, valuelabel) /// ylabel(-.4(.1).4) /// yline(0, lc(red))
Do you any helpful clue? Would be very appreciated.
Thanks, G
0 Response to Twoway graph with one legend in common
Post a Comment