# RE: st: RE: Create graph directly from matrix?

 From "Nick Cox" To Subject RE: st: RE: Create graph directly from matrix? Date Mon, 16 Nov 2009 17:43:14 -0000

```I agree. This is clever. But there is no new principle here. _n in any
expression yielding a new variable is interpreted observation by
observation.

Nick
n.j.cox@durham.ac.uk

Nick Winter

Ah, interesting.

Looking within -_matplot-, it looks like the fundamental answer to my
question might be "no", since that program creates temporary variables
that it then plots.

But it uses an interesting construction that may help me go the
variables route without using -svmat-:

gen x = Xy[_n,1] in 1/16

creates a new variable -x- from the first column of matrix Xy.  Pretty
spiffy to use _n to tag the observation number/row number.

- Nick

Nick Cox wrote:
> Check out the undocumented command -_matplot-.
>
> Nick
> n.j.cox@durham.ac.uk
>
> Nick Winter
>
> I'm wondering if there is a way to convert the values held into a
matrix
>
> into a graph (ie, into a serset that serves as the basis for a graph)
> directly, without first making the matrix into variables?
>
> Why I'm curious:
>
> I'm thinking about revising my -oprobpr- command, which plots
predicted
> probabilities after order l/probit models.  The new -margins- command
> can fairly easily calculate what's required for the plotting, and
those
> results can be saved as a matrix, using -margins-'s -post- option.
>
> So I'd like to plot the estimates returned in e(b) against values in
> e(at).
>
> I can put this stuff all together in one matrix, eg:
>
> sysuse auto
> probit foreign mpg price weight
>
> margins, atmeans at(mpg=(12(2.9)41)) post
> mat b = e(b)
> mat X = e(at)
> mat Xy = X , b'
>
> Then I'd like to create, eg, a line plot of the final column (named
y1)
> against the first column (mpg).
>
> I can, of course, use -svmat-, graph the relevant variables, and drop
> the variables.
>
> But I'd love a more elegant solution.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.7801909,"math_prob":0.6845137,"size":2333,"snap":"2023-14-2023-23","text_gpt3_token_len":666,"char_repetition_ratio":0.08844998,"word_repetition_ratio":0.020253165,"special_character_ratio":0.2850407,"punctuation_ratio":0.16075157,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96096206,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-05-30T17:17:54Z\",\"WARC-Record-ID\":\"<urn:uuid:3511efa7-2ca6-4291-a24c-2658451a77d4>\",\"Content-Length\":\"8993\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:56dee186-b6b4-4ee4-bc72-80aab3c63d97>\",\"WARC-Concurrent-To\":\"<urn:uuid:b9f64ed7-2b2c-40e5-bb5b-a170113924b4>\",\"WARC-IP-Address\":\"66.76.6.5\",\"WARC-Target-URI\":\"https://www.stata.com/statalist/archive/2009-11/msg00837.html\",\"WARC-Payload-Digest\":\"sha1:L7U44OEMWEGQX57AAOW2XA5HZO2LOGT4\",\"WARC-Block-Digest\":\"sha1:CR23776D7RK7ZFKS7MIDJADVAQSGSKMP\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224646076.50_warc_CC-MAIN-20230530163210-20230530193210-00366.warc.gz\"}"}