Hi,
I am generating multiple scatter plots with a logarithmic y-axis using foreach loops, however I am having problems with getting the ylabels look nice. I found Nick Cox's "forval" code (https://www.stata.com/statalist/arch.../msg00770.html), and it partially works, but it creates a massive range from min to max, and I'm not sure why so. I am running Stata15 on macOS.
My y-values are various protein measurements ranging from 0.0001 units to 10000 units (variables differ in range; these given here are the absolute min and max); but rather I get labelling of log10 units ranging from 10E-6 to 10E9..
My code looks like this:
the
part is just to see what `labels' contains. For one variable with min-max being 150-13106, it returns "1000000 10000000 100000000 1000000000 1.00000000000e-06 .00001 .0001 .001 .01 .1 1".
I don't know how to solve this. Can you help? It's my first post here, apologies if I did not include all necessary info.
Best,
Mads
I am generating multiple scatter plots with a logarithmic y-axis using foreach loops, however I am having problems with getting the ylabels look nice. I found Nick Cox's "forval" code (https://www.stata.com/statalist/arch.../msg00770.html), and it partially works, but it creates a massive range from min to max, and I'm not sure why so. I am running Stata15 on macOS.
My y-values are various protein measurements ranging from 0.0001 units to 10000 units (variables differ in range; these given here are the absolute min and max); but rather I get labelling of log10 units ranging from 10E-6 to 10E9..
My code looks like this:
Code:
foreach y in varlist" { display "statistics for: `y', Gene 1" kwallis `y' if diaggroup==1, by(gene1mut) display "statistics for: `y', Gene 2" kwallis `y' if diaggroup==1, by(gene2mut) su `y', meanonly local min = ceil(log(r(min))) local max = floor(log(r(max))) forval i = `min'/`max' { local labels "`labels' `=10^(`i')'" } di " `labels' -" twoway (scatter `y' mut_status if mut_status==0 & diaggroup==1, jitter(3)) (scatter `y' mut_status if mut_status==1 & diaggroup==1, jitter(3)) (scatter `y' mut_status if mut_status==2 & diaggroup==1, jitter(3)), name(`y', replace) xscale(range(-0.5 2.5)) xlabel(0 "No mutation" 1 "Gene 1" 2 "Gene 2") yscale(log) ylabel(`labels') }
Code:
di " `labels' -"
I don't know how to solve this. Can you help? It's my first post here, apologies if I did not include all necessary info.
Best,
Mads
Comment