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: Changing line color for more than 20 overlaid twoway line plots


From   Roth Florian <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Changing line color for more than 20 overlaid twoway line plots
Date   Thu, 31 Jan 2013 21:00:48 +0100

Dear Nick,

Thank you very much for answering so quickly. Your solution works great and since I am doing the line plot repeatedly I can see why blanking out the macro is so important.

Best,
Florian
________________________________________
Von: [email protected] [[email protected]] im Auftrag von Nick Cox [[email protected]]
Gesendet: Donnerstag, 31. Januar 2013 18:12
An: [email protected]
Betreff: Re: st: Changing line color for more than 20 overlaid twoway line plots

You raise a good point.

My code should indeed work fine without explicit blanking out of the
-local- macro. But I decided to include that line for a reason that I
am now happy to explain.

I find that most graphs require numerous minor tweaks. Or rather, my
personal style is to get a very rough graph quickly and then make all
sorts of minor adjustments. For anything complicated I move from the
Command window to a do-file editor window and run revised code again
and again. So, I wanted to underline that's a good style to blank out
the macro before each new graph run.

Otherwise the iterative

local call `call' <new stuff>

will mean that syntax just accumulates like dirt on a shoe.

I also want to emphasise my personal opinion that working with
undefined macros can be excellent style and in no sense an error.

Nick

On Thu, Jan 31, 2013 at 4:33 PM, Klaus Pforr <[email protected]> wrote:
> <>
>
> Dear Nick,
>
> your solution reminds me of a discussion, which appeared recently in the
> wishlist-posts:
>
> Should macros be declared or initialized, or otherwise cause an error. In
> your code you used this line
> ###
> local call
> ###
> i.e. you initialized the macro to a zero content. The code should work
> without this line, shouldn't it (yes, why not just try it, before you
> ask...)? Is this just a better coding style?
>
> best wishes
>
> Klaus
>
> __________________________________
>
> Klaus Pforr
> GESIS -- Leibniz Institut für Sozialwissenschaft
> B2,1
> Postfach 122155
> D - 68072 Mannheim
> Tel: +49 621 1246 298
> Fax: +49 621 1246 100
> E-Mail: [email protected]
> __________________________________
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Nick Cox
> Gesendet: Donnerstag, 31. Januar 2013 17:17
> An: [email protected]
> Betreff: Re: st: Changing line color for more than 20 overlaid twoway line
> plots
>
> set obs 100
> forval j = 1/22 {
>         gen var`j' = rnormal()
> }
> gen year = 1900 + _n
>
> local call
>
> forval j = 2/22 {
>    local call `call' line var`j' year, lc(gs10) || }
>
> twoway `call' || line var1 year, lc(black) legend(off)
>
>
> On Thu, Jan 31, 2013 at 4:06 PM, Roth Florian <[email protected]> wrote:
>> Dear All,
>>
>> I am trying to make a number of overlaid twoway line plots for a variable
> (e.g. var1-var22) in a wide panel data set.
>> For this I use the Stata command:
>>
>>         . twoway line var1-var22 Year
>>
>> Now, I would like to change the line color of var2-var22 to grey and the
> line of var1 to black. So I use:
>>
>>         . twoway line var1-var22 Year, lcolor(black gs10 ...)
>>
>> I then get the error:
>>
>>         . p21(line(color(blue)) area(linestyle(color(blue)))):  too
>> many arguments
>>
>> It seem as if lcolor does not allow for more than 20 arguments.
>>
>> Now, I could transform my data to long format and use - xtline - with
>> options - overlay - and -plot#opts() - but then I would have to set
>> the color for every line separately. This is not very practical because I
> would like to make the same plot for many different data sets with a varying
> number of line plots overlaid.
>>
>> I care only about visually distinguishing var1 from the rest. So maybe
> there is a way to threat var2-var22 as a group.
>> Or is there any other way to change the line color for a number of
> overlaid line plots.
>>

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


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