Hello,
I am seeking assistance with overlaying a histogram graph on top of a line graph. While I understand this can be achieved easily using twoway and manipulating different x and y axes, I have a specific requirement: I want the histogram to occupy only 1/4 of the y-axis height.
In theory, I can accomplish this using gr_edit by determining the maximum of the y-axis and then multiplying it by 4. However, since I need to generate numerous graphs automatically, manual intervention to determine the maximum of the y-axis for each graph is impractical.
Is there a method to automatically determine the maximum of the y-axis? Alternatively, do you know of any workarounds I could utilize?
Here's an example of the code I'm currently attempting to use, where 0.428 represents the maximum of the y-axis:
Any help would be greatly appreciated!
I am seeking assistance with overlaying a histogram graph on top of a line graph. While I understand this can be achieved easily using twoway and manipulating different x and y axes, I have a specific requirement: I want the histogram to occupy only 1/4 of the y-axis height.
In theory, I can accomplish this using gr_edit by determining the maximum of the y-axis and then multiplying it by 4. However, since I need to generate numerous graphs automatically, manual intervention to determine the maximum of the y-axis for each graph is impractical.
Is there a method to automatically determine the maximum of the y-axis? Alternatively, do you know of any workarounds I could utilize?
Here's an example of the code I'm currently attempting to use, where 0.428 represents the maximum of the y-axis:
Code:
clear set obs 1000 set seed 12 gen dist=rnormal() sort dist gen yvar=dist^2 tw (line yvar dist) (hist dist, xaxis(2) yaxis(2)) gr_edit .yaxis2.plotregion.yscale.curmax = 0.428*4
Comment