Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: SV: how do I overlay two linkplot graphs?: now trying -xtline-


From   Stephen Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: SV: how do I overlay two linkplot graphs?: now trying -xtline-
Date   Thu, 13 Dec 2007 17:07:57 +1000

Hmmm, sorry for my confusing first attempt. After I sent it I realised I had not said I had changed my data to long form.

Here is my data format:

GRP Task Character Score
1       1       1       40
1       1       2       44
1       1       3       11
1       1       4       78
1       1       5       38
1       2       1       42
1       2       2       46
1       2       3       17
1       2       4       71
1       2       5       42
2       1       1       40
2       1       2       44
2       1       3       11
2       1       4       78
2       1       5       38
2       2       1       42
2       2       2       46
2       2       3       17
2       2       4       71
2       2       5       42
Etc

For each GRP (group), I am wanting to get two line graphs for Score against Character, one graph for each Task. And I want all graphs overlayed.


Lets assume I have only the values for Task = 1.

After defining the dat set to be a panel data using

 . tsset GRP character

Then using the following command:

.xtline score, overlay legend (off)

I can get a graph for Task = 1 in the form I want.



But I want to have another graph for Task=2, and have those graphs overlayed.

I am unsure how to do this with -xtline-, as I think I would need two 'score' variables, one for each Task, but then I can't use the overlay option.



I am not sure how to do this with -linkplot- (from SSC) either.

And ultimately I will have to do it all for some different subsets of cases as I have 203 GRPs which will be too many too see on one graph, but that is another learning task for me.

I hope this helps.

______________________________________
Stephen Cox |


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Thursday, 13 December 2007 12:56 AM
To: [email protected]
Subject: st: RE: SV: how do I overlay two linkplot graphs?

Kim's suggestion won't work. -linkplot- cannot be used in this
way, as it is only a stand-alone program and not also
a -twoway- type.

To answer the original question, and one of the doubts in
Kim's reply, -linkplot- is a program from SSC.

Only yesterday in a different thread I was saying,

"Please remember the advice to specify where user-written
commands you refer to may be located."

That advice is spelled out in the FAQ, which all members
are asked to read before posting.

-linkplot- dates from 2003 and was written for version 8.
One of its options is -plot()-. I will revise -linkplot-
to support also -addplot()- for users of Stata 9 or 10.
-plot()- will still work in Stata 9 or 10, but is now undocumented.

The criterion for -plot()- (or -addplot()-) is simple. Its argument
must be capable of being fed to -twoway- as a -twoway- type.
Stephen fed to -plot()-

if task==1, linepattern(solid) if task==2, linepattern(dot)

but that isn't a self-contained -twoway- type call. Nor is it
legal syntax for any other Stata purpose. Nor would something
like

. linkplot score character, link(GRP) if task ==1,
        plot(linkplot score character if task==2)

work, for the reason given in my first sentence.

I can't work out from Stephen's posting precisely what he wants.
He refers to variables -character1-character5- but he
is trying graph calls using -character-. Unless -character-
is a separate variable there is no way that is going
to work.

I have to guess at this stage that Stephen is expecting from
-linkplot- something that goes way beyond its specification.
It should do what is claimed in its help, but no more.

Further progress might depend on Stephen posting a sample
dataset with precisely his kind of structure. What he wants
will be plottable, but not necessarily with -linkplot-.

Nick
[email protected]

Kim Lyngby Mikkelsen
====================

Overlaying graphs is done using the '||'-option between plots you want
to overlay.

Try something like this:

linkplot score character if task==1, link(GRP) linepattern(solid) ||
linkplot score character if task==2, link(GRP) linepattern(dot))

Obs: everything should be written within the same line!
Obs: I am not familiar with the linkplot command, and I do not know if
the part of your command after the comma is correct. I have removed your
specification of 'plot' as I can see that this option requires an
argument, which I think might be the name of another plot you have
previous saved.

Stephen Cox (edited)
===========

For each case, I have 2 (task 1, task 2) sets of 5 variables (character1
- 5).
I want to do a -linkplot- across the 5 character variables, one for each
task
set, but overlayed, and with a different line patterns for each tasks.

I'm quite new to Stata, and can't work out how the -plot()- option
works.
The help seems to say it allows -twoway connected- graph options, but I
keep
getting error messages.

I can't define line patterns, nor get the two sets of lines to go on the
same
graph. I am obviously not using the -plot()- options correctly here, but
can't work out how.

Here is one of the many many attempts I have had:

. linkplot score character, link(GRP) plot (if task==1,
linepattern(solid) if task==2, linepattern(dot))

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index