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]

AW: st: Changing line color for more than 20 overlaid twoway line plots


From   "Klaus Pforr" <[email protected]>
To   <[email protected]>
Subject   AW: st: Changing line color for more than 20 overlaid twoway line plots
Date   Thu, 31 Jan 2013 17:33:19 +0100

<>

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.
>
> Thank you for your consideration.
>
> Best regards,
> Florian
>
> *
> *   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/


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