Hello everyone,
I’m trying to display two separate legends on the same graph. I searched through previous discussions but couldn’t find an answer to this specific issue.
In my case, I would like to keep the legend for 1, 2, 3 with their colors at the bottom, and place the legend for the two lines at the top, but I haven’t been able to separate the two.
If anyone has a solution or suggestion, I would really appreciate your help.
Thanks in advance,
John

I’m trying to display two separate legends on the same graph. I searched through previous discussions but couldn’t find an answer to this specific issue.
In my case, I would like to keep the legend for 1, 2, 3 with their colors at the bottom, and place the legend for the two lines at the top, but I haven’t been able to separate the two.
If anyone has a solution or suggestion, I would really appreciate your help.
Thanks in advance,
John
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float(monthly_date cumulative_count target_count base2 base5 base6 top2 top5 top6)
768 3 1.1 0 1 1 1 1 2
769 4 2.2 0 0 0 0 0 1
770 8 3.3 0 0 3 0 3 3
771 9 4.4 0 0 0 0 0 1
772 10 5.5 0 0 1 0 1 1
773 11 6.6 0 0 0 0 0 1
774 13 7.7 0 0 0 0 0 0
775 15 8.8 0 0 0 0 0 0
776 15 9.9 0 0 0 0 0 0
777 15 11 0 0 0 0 0 0
778 15 12.1 0 0 0 0 0 0
779 15 13.2 0 0 0 0 0 0
780 15 14.3 0 0 0 0 0 0
781 15 15.4 0 0 0 0 0 0
782 15 16.5 0 0 0 0 0 0
783 15 17.6 0 0 0 0 0 0
784 15 18.7 0 0 0 0 0 0
end
format %tmm_CY monthly_date
twoway (rbar base2 top2 monthly_date, color(blue)) ///
(rbar base5 top5 monthly_date, color(red)) ///
(rbar base6 top6 monthly_date, color(green)) ///
(line cumulative_count monthly_date, yaxis(2)) ///
(line target_count monthly_date, lpattern(shortdash_dot) yaxis(2)), ///
xtitle("") ///
legend(order(1 "1" 2 "2" 3 "3" 4 "Solid line" 5 "Dashed line") pos(6) col(5) size(vsmall)) //

Comment