Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Mauricio Esteban Cuak <cuak2000@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Making a bar graph from the row of a matrix |
Date | Mon, 8 Apr 2013 10:49:38 -0500 |
Hi Nick, thanks for the answer. The following code plots the graph I wanted and may be useful for other people. It doesn't look very nice however. As suggested by Nick, I moved the names into a variable (slightly tricky) and the values into another. /* Begin CODE */ clear all sysuse auto.dta qui reg price mpg trunk weight matrix test = e(V) matrix rowtest = test["weight", 1...] /* rowtest is the row I want to graph */ local names : colnames rowtest local n_names : word count `names' gen var_colnames = "" forval i=1/`n_names' { local this_name = "`:word `i' of `names''" replace var_colnames = "`this_name'" if _n == `i' } matrix trans_rowtest = rowtest' svmat trans_rowtest graph bar trans_rowtest1, over(var_colnames) ************************************** 2013/4/7 Mauricio Esteban Cuak <cuak2000@gmail.com> > > Hi Nick, thanks for the answer. > The following code plots the graph I wanted and may be useful for other people. > It doesn't look very nice however. > As suggested by Nick, I moved the names into a variable (slightly tricky) and the values into another. > > > **************BEGIN CODE******************** > > clear all > > sysuse auto.dta > > qui reg price mpg trunk weight > > matrix test = e(V) > > > matrix rowtest = test["weight", 1...] > > /* rowtest is the row I want to graph */ > > > local names : colnames rowtest > > local n_names : word count `names' > > > gen var_colnames = "" > > forval i=1/`n_names' { > > local this_name = "`:word `i' of `names''" > > replace var_colnames = "`this_name'" if _n == `i' > > } > > matrix trans_rowtest = rowtest' > > svmat trans_rowtest > > graph bar trans_rowtest1, over(var_colnames) > > > > > > > 2013/4/3 Nick Cox <njcoxstata@gmail.com> >> >> The easiest way to do this is probably to copy values from your matrix >> to a variable and then call up -twoway bar-. >> >> Nick >> * >> * For searches and help try: >> * http://www.stata.com/help.cgi?search >> * http://www.stata.com/support/faqs/resources/statalist-faq/ >> * http://www.ats.ucla.edu/stat/stata/ > > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/