Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: copy graph legend


From   "Fiedler, James (JSC-SK)[UNIVERSITIES SPACE RESEARCH ASSOC-DIV OF SPACE LIFE SCIENCES]" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: copy graph legend
Date   Wed, 9 May 2012 17:43:43 -0500

It also sounds like the changes you already made were not recorded, and, if at all possible, you'd like to avoid repeating those edits. Here's something that's working for me, but it doesn't work in all cases, and might be destructive when it doesn't work. 

*** Do the following only if you're prepared to destroy your current graphs. Save a copy before proceeding.***

First, is your graph named? If so, take "graph1" to be that name, otherwise replace "graph1" with "Graph". I'm going to assume the other graphs have not yet been made. When you make them, give them a name, and put that name in place of "graph2" below.

So you'll do
  twoway  etc etc , name(graph2)

Or whatever, then
  .graph2.legend = .graph1.legend
  graph draw graph2


In the second-to-last line, you need to type the periods before "graph1" and "graph2".

I'm curious to know if that works. I made one kind of edit with the graph editor and it worked, and when I made another kind of edit it destroyed one of the graphs.

Here's an example where it works for me (Stata 12 on Windows XP):

    scatter mpg turn weight, name(graph1)

*** use graph editor to erase "(mpg)" and "(ft.)", then exit editing mode ***

    scatter length trunk price, name(graph2)
    .graph2.legend = .graph1.legend
    graph draw graph2

James

________________________________________
From: [email protected] [[email protected]] On Behalf Of Nick Cox [[email protected]]
Sent: Wednesday, May 09, 2012 4:01 PM
To: [email protected]
Subject: Re: st: copy graph legend

I think I was reading this the wrong way. Ric is referring to changes
made in the Graph Editor. The Graph Recorder is the way to record what
it does.

Nick

On Wed, May 9, 2012 at 9:39 PM, Nick Cox <[email protected]> wrote:
> Use a local macro for your legend definition.
>
> Here's a dopey example:
>
> sysuse auto, clear
>
> local mylegend "legend(pos(3) col(1))"
> local myytitle "Turn circle (ft) and trunk space (cu. ft)"
>
> forval i = 1/5 {
>        scatter turn trunk weight if rep78==`i', ///
>        ytitle(`myytitle') subtitle(Repair record `i') `mylegend'
>        more
> }
>
>
> On Wed, May 9, 2012 at 9:28 PM, Eric M. Uslaner <[email protected]> wrote:
>
>  I am generating a set of similar graphs and I don't like the legend
> Stata automatically produces.  I spent considerable time formatting
> the legend in the first graph.  If at all possible, I would like to
> copy the legend and replace legends in graphs 2-4 with the legend I
> created for graph 1.  I searched for help and could not find a
> solution.  If I could recover the commands for the edited legend in
> graph 1, I could redo the other graphs with the revised legend in the
> command line since the rest of the graph is barely edited from what
> Stata generates.  I have read the manual on legends--and larning all
> of the comands would take a lot more time than editing each one.  I am
> hoping (though not so optimistically) for a simple 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/

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index