Search code examples
statascatter-plot

How can I put the x axis on top in Stata?


I'm sorry if this question has been asked before, I couldn't find it anywhere.

I just want to "move" the x axis from the bottom of the graph to the top. So "10" on the x axis should be next to "10" on the y axis (I hope this makes sense).

this is the graph

Here's my code:

twoway scatter h a, xscale(log) yscale(log) ///
xscale(r(10 100000)) ///
yscale(r(0.0000001 0.1)) ///
xlabel(10 100 1000 "1'000" 10000 "10'000" 100000 "100'000", grid labsize(small)) ///
ylabel(1 "10" 0.1 "100" 0.01 "1'000" 0.001 "10'000" 0.0001 "100'000" 0.00001 "1 Mio." 0.000001 "10 Mio." 0.0000001 "100 Mio.", angle(0) labsize(small)) ///
xtitle("{bf:Gesamtschaden}" "Mio. CHF", /// 
    size(small)) ///
ytitle("{bf:Häufigkeit}" "1 x in ... Jahren", ///
    size(small)) ///

Many thanks in advance!


Solution

  • You can use axis suboption alt to alternate the default location of an axis (i.e. if default is bottom, alt will move it to the top)

    twoway scatter h a, xscale(log alt) yscale(log) ///
    xscale(r(10 100000)) ///
    yscale(r(0.0000001 0.1)) ///
    xlabel(10 100 1000 "1'000" 10000 "10'000" 100000 "100'000", grid labsize(small)) ///
    ylabel(1 "10" 0.1 "100" 0.01 "1'000" 0.001 "10'000" 0.0001 "100'000" 0.00001 "1 Mio." 0.000001 "10 Mio." 0.0000001 "100 Mio.", angle(0) labsize(small)) ///
    xtitle("{bf:Gesamtschaden}" "Mio. CHF", /// 
        size(small)) ///
    ytitle("{bf:Häufigkeit}" "1 x in ... Jahren", ///
        size(small)) ///