Hello all,
I'm working in this graph, but when I have few samples in y-axis a large gap appears between the samples in the graph. I tried everything from fixing sizes, margins and aspect ratio but I cannot find a coding solution for this.
Could you help me?

When I have many samples, the graph aspect is fine as the Samples are evenly distribuited in the yaxis:

I was able to artificially solve the problem by increasing the yscale without observations. This would solve the problem if I cut the graph using a image processing software, but I want to find a coding solution for this as this code will be inserted in a program:

Is there a way to remove this large gap between the observations when few itens are added in the y-scale? Or to cut the extra top space from my artifical solution?
Thank you in advance,
With the best wishes
Rafael
I'm working in this graph, but when I have few samples in y-axis a large gap appears between the samples in the graph. I tried everything from fixing sizes, margins and aspect ratio but I cannot find a coding solution for this.
Could you help me?
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input byte parameter str4(first second) byte(first_xaxis second_xaxis)
1 "red" "blue" 0 1
2 "blue" "red" 0 1
end
set scheme s2color
gen yaxis = _n
replace yaxis = yaxis - 1
twoway (scatter yaxis first_xaxis if first == "blue", msymbol(O) mcolor(blue%30) msize(medlarge)) (scatter yaxis first_xaxis if first == "red", msymbol(O) mcolor(red%30) msize(medlarge)) (scatter yaxis second_xaxis if second == "blue", msymbol(O) mcolor(blue%30) msize(medlarge)) (scatter yaxis second_xaxis if second == "red", msymbol(O) mcolor(red%30) msize(medlarge)), /*
*/ yscale(range(0 1)) ytitle("", size(small))/*
*/ ylabel(0 "Sample 1" 1 "Sample 2", angle(0) labsize(vsmall) notick nogrid) /*
*/ xscale(range (0 1) titlegap(5)) xtitle("", size(small)) /*
*/ xlabel(0 "Parameter 1" 1 "Parameter 2", angle(vertical) labsize(vsmall) notick) /*
*/ leg(off) graphregion(color(white))
When I have many samples, the graph aspect is fine as the Samples are evenly distribuited in the yaxis:
Code:
clear all
* Example generated by -dataex-. For more info, type help dataex
clear
input byte parameter str4(first second) byte(first_xaxis second_xaxis)
1 "red" "blue" 0 1
2 "blue" "red" 0 1
3 "blue" "red" 0 1
4 "blue" "red" 0 1
5 "blue" "red" 0 1
6 "blue" "red" 0 1
7 "blue" "red" 0 1
8 "blue" "red" 0 1
9 "blue" "red" 0 1
10 "blue" "red" 0 1
11 "blue" "red" 0 1
end
set scheme s2color
gen yaxis = _n
replace yaxis = yaxis - 1
twoway (scatter yaxis first_xaxis if first == "blue", msymbol(O) mcolor(blue%30) msize(medlarge)) (scatter yaxis first_xaxis if first == "red", msymbol(O) mcolor(red%30) msize(medlarge)) (scatter yaxis second_xaxis if second == "blue", msymbol(O) mcolor(blue%30) msize(medlarge)) (scatter yaxis second_xaxis if second == "red", msymbol(O) mcolor(red%30) msize(medlarge)), /*
*/ yscale(range(0 10)) ytitle("", size(small))/*
*/ ylabel(0 "Sample 1" 1 "Sample 2", angle(0) labsize(vsmall) notick nogrid) /*
*/ xscale(range (0 1) titlegap(5)) xtitle("", size(small)) /*
*/ xlabel(0 "Parameter 1" 1 "Parameter 2", angle(vertical) labsize(vsmall) notick) /*
*/ leg(off) graphregion(color(white))
I was able to artificially solve the problem by increasing the yscale without observations. This would solve the problem if I cut the graph using a image processing software, but I want to find a coding solution for this as this code will be inserted in a program:
Code:
clear all
* Example generated by -dataex-. For more info, type help dataex
clear
input byte parameter str4(first second) byte(first_xaxis second_xaxis)
1 "red" "blue" 0 1
2 "blue" "red" 0 1
end
set scheme s2color
gen yaxis = _n
replace yaxis = yaxis - 1
twoway (scatter yaxis first_xaxis if first == "blue", msymbol(O) mcolor(blue%30) msize(medlarge)) (scatter yaxis first_xaxis if first == "red", msymbol(O) mcolor(red%30) msize(medlarge)) (scatter yaxis second_xaxis if second == "blue", msymbol(O) mcolor(blue%30) msize(medlarge)) (scatter yaxis second_xaxis if second == "red", msymbol(O) mcolor(red%30) msize(medlarge)), /*
*/ yscale(range(0 10)) ytitle("", size(small))/*
*/ ylabel(0 "Sample 1" 1 "Sample 2", angle(0) labsize(vsmall) notick nogrid) /*
*/ xscale(range (0 1) titlegap(5)) xtitle("", size(small)) /*
*/ xlabel(0 "Parameter 1" 1 "Parameter 2", angle(vertical) labsize(vsmall) notick) /*
*/ leg(off) graphregion(color(white))
Is there a way to remove this large gap between the observations when few itens are added in the y-scale? Or to cut the extra top space from my artifical solution?
Thank you in advance,
With the best wishes
Rafael

Comment