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   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Changing line color for more than 20 overlaid twoway line plots
Date   Thu, 31 Jan 2013 16:17:04 +0000

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/


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