Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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/

**Follow-Ups**:**Re: st: Making a bar graph from the row of a matrix***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: How to apply sktest to panel data?** - Next by Date:
**st: How to use local Windows Environment Variable when running Stata via RemoteApp ?** - Previous by thread:
**Re: st: Making a bar graph from the row of a matrix** - Next by thread:
**Re: st: Making a bar graph from the row of a matrix** - Index(es):