I am trying to use GRAPH3D to plot and I need some help to annotate the graph. For example, would be useful adding a reference plane, such as (x, y=0, z). I also would like to change the size of the labels. Help is appreciated.
I am including some example code here, in case someone wants to reproduce it:
I am including some example code here, in case someone wants to reproduce it:
Code:
set more off /* load data */ clear sysuse auto set matsize 11000 center price mpg length, standardize replace /* estimate model: CHANGE MODEL HERE */ reg c_price i.foreign##c.c_mpg##c.c_mpg i.foreign##c.c_length##c.c_length summ price foreign mpg length /* specify values of x and y at which margins are calculated: CHANGE VALUES HERE */ local xfrom -1 local xto 1 local xstep .1 local zfrom -1 local zto 1 local zstep .1 /* post margins in matrix e(b) at specified values of the x and y variables: CHANGE VARIABLE FOR MARGINAL EFFECT HERE */ margins i.foreign, at(c_mpg=(`xfrom'(`xstep')`xto') c_length=(`zfrom'(`zstep')`zto')) post /* construct variable z */ mat b = e(b) mat mgns = b[1...,1...]' svmat double mgns, name(mgn) ren mgn1 y replace y=y*1 /* scale z variable to make it more visible: CHANGE SCALING HERE */ summ y /* construct variables x and z -- observe that the response variable is y (not z) */ gen x = . gen z = . gen m = . local pos=1 forv lx = `xfrom'(`xstep')`xto' { forv lz = `zfrom'(`zstep')`zto' { forv lm =0(1)1 { local lx = round(`lx',.0001) local lz = round(`lz',.0001) qui replace x = `lx' in `pos' qui replace z = `lz' in `pos' qui replace m = `lm' in `pos' local pos=`pos'+1 } } } /* plot variables x, y, and z: CHANGE OPTIONS HERE */ graph3d x y z m, /// ///xangle(88) yangle(179) zangle(45) xcam(-30) zcam(200) /// aspectratio(1) /// mark cuboid innergrid blv perspective colorscheme(cr) /// /// xlang(90) ylang(30) zlang(-12) xlpos(9) ylpos(4) zlpos(12) /// /// xang(15) yang(80) /// xlab("mpg") ylab("length") zlab("price") /// /// xlang(315) ylang(90) zlang(0) /// /// xlpos(11) ylpos(3) zlpos(11) /// markeroptions(msize(tiny)) graph export "car_prices.png", replace