Hi all.
I have a data set in which many coded docs are represented. Each document has a serial number (doc), and it spreads on several cases which are also numbered (line), and there are some more something like that: doc line A B C D E F G 182 330 3 0 0 0 0 0 0 182 340 4 1 0 0 0 0 1 182 350 5 3 0 0 0 0 2 182 360 4 2 0 0 0 0 1 182 370 5 1 0 0 0 0 1 182 380 2 1 1 0 0 0 1 183 380 2 3 3 1 0 1 0 183 390 0 1 0 1 0 0 0 183 400 3 3 0 1 0 0 1 183 410 1 3 0 1 0 0 0 183 420 0 0 0 0 0 0 0 185 420 5 6 3 1 0 1 3 185 430 1 6 3 1 0 1 2 186 430 4 2 3 1 0 0 0 186 440 3 5 3 1 0 0 1 186 450 6 3 1 1 0 0 0 186 460 5 1 1 0 0 0 1 186 470 9 0 1 0 0 0 0 186 480 0 0 0 0 0 0 0 189 480 12 0 1 0 0 0 0 189 490 6 0 0 0 0 0 0 189 500 9 1 0 0 0 0 1 189 510 11 0 2 0 0 0 0 189 520 0 0 0 0 0 0 0 196 520 1 0 0 0 0 0 0 196 530 2 1 0 1 0 0 0 196 540 0 1 0 0 1 0 0 196 550 0 3 0 0 2 0 1 196 560 0 2 0 0 1 0 0 196 570 1 0 0 0 0 0 0 196 580 0 0 0 0 0 0 0 for this ex. I would like to have 6 charts, one for each doc (182,183,185,186,189,196), which the x axis will consist of the line number and the y axis will show the levels for each variables (A..G). can anyone help? thanks! Uri. it |
Here is an example reshaping the letter columns into one column using VARSTOCASES and then using SPLIT FILE to create seperate charts for each doc.
**************************************************. DATA LIST FREE / doc line A B C D E F G. BEGIN DATA 182 330 3 0 0 0 0 0 0 182 340 4 1 0 0 0 0 1 182 350 5 3 0 0 0 0 2 182 360 4 2 0 0 0 0 1 182 370 5 1 0 0 0 0 1 182 380 2 1 1 0 0 0 1 183 380 2 3 3 1 0 1 0 183 390 0 1 0 1 0 0 0 183 400 3 3 0 1 0 0 1 183 410 1 3 0 1 0 0 0 183 420 0 0 0 0 0 0 0 185 420 5 6 3 1 0 1 3 185 430 1 6 3 1 0 1 2 186 430 4 2 3 1 0 0 0 186 440 3 5 3 1 0 0 1 186 450 6 3 1 1 0 0 0 186 460 5 1 1 0 0 0 1 186 470 9 0 1 0 0 0 0 186 480 0 0 0 0 0 0 0 189 480 12 0 1 0 0 0 0 189 490 6 0 0 0 0 0 0 189 500 9 1 0 0 0 0 1 189 510 11 0 2 0 0 0 0 189 520 0 0 0 0 0 0 0 196 520 1 0 0 0 0 0 0 196 530 2 1 0 1 0 0 0 196 540 0 1 0 0 1 0 0 196 550 0 3 0 0 2 0 1 196 560 0 2 0 0 1 0 0 196 570 1 0 0 0 0 0 0 196 580 0 0 0 0 0 0 0 END DATA. FORMATS ALL (F3.0). VARSTOCASES /MAKE Val FROM A TO G /INDEX Let (Val). *Split file for seperate charts. SPLIT FILE BY doc. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=line Val Let /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: line=col(source(s), name("line")) DATA: Val=col(source(s), name("Val")) DATA: Let=col(source(s), name("Let"), unit.category()) GUIDE: axis(dim(1), label("line")) GUIDE: axis(dim(2), label("Val"), delta(1)) GUIDE: legend(aesthetic(aesthetic.color.exterior)) ELEMENT: point(position(line*Val), shape(Let)) END GPL. SPLIT FILE OFF. **************************************************. Another option besides SPLIT FILE is to make a small multiple chart. **************************************************. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=line Val Let doc /GRAPHSPEC SOURCE=INLINE. BEGIN GPL PAGE: begin(scale(700px,700px)) SOURCE: s=userSource(id("graphdataset")) DATA: line=col(source(s), name("line")) DATA: Val=col(source(s), name("Val")) DATA: Let=col(source(s), name("Let"), unit.category()) DATA: doc=col(source(s), name("doc"), unit.category()) COORD: rect(dim(1,2), wrap()) GUIDE: axis(dim(1), label("line")) GUIDE: axis(dim(2), label("Val"), delta(1)) GUIDE: axis(dim(3), opposite()) ELEMENT: point(position(line*Val*doc), shape(Let)) PAGE: end() END GPL. **************************************************. You will notice that these have a severe overlapping problem. One way I've dealt with this in the past is to use jittering and/or semi-transparent shapes. (See here for another example, http://stats.stackexchange.com/a/19543/1036.) You may consider using a sequential color scheme as well if the letters are intended to be ordinal (e.g. A is dark and G is light). **************************************************. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=line Val Let doc /GRAPHSPEC SOURCE=INLINE. BEGIN GPL PAGE: begin(scale(700px,700px)) SOURCE: s=userSource(id("graphdataset")) DATA: line=col(source(s), name("line")) DATA: Val=col(source(s), name("Val")) DATA: Let=col(source(s), name("Let"), unit.category()) DATA: doc=col(source(s), name("doc"), unit.category()) COORD: rect(dim(1,2), wrap()) GUIDE: axis(dim(1), label("line")) GUIDE: axis(dim(2), label("Val"), delta(1)) GUIDE: axis(dim(3), opposite()) ELEMENT: point.dodge.symmetric(position(bin.rect.centroid(line*Val*doc, dim(2), binWidth(1))), transparency.exterior(transparency."0.3"), transparency.interior(transparency."0.5"), color.interior(Let), color.exterior(Let), shape(Let)) PAGE: end() END GPL. **************************************************. In this circumstance just displaying the letters SPSS does a pretty good job of displacing the labels **************************************************. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=line Val Let doc /GRAPHSPEC SOURCE=INLINE. BEGIN GPL PAGE: begin(scale(900px,600px)) SOURCE: s=userSource(id("graphdataset")) DATA: line=col(source(s), name("line")) DATA: Val=col(source(s), name("Val")) DATA: Let=col(source(s), name("Let"), unit.category()) DATA: doc=col(source(s), name("doc"), unit.category()) COORD: rect(dim(1,2), wrap()) GUIDE: axis(dim(1), label("line")) GUIDE: axis(dim(2), label("Val"), delta(1)) GUIDE: axis(dim(3), opposite()) ELEMENT: point(position(line*Val*doc), transparency.exterior(transparency."1"), label(Let, showAll())) PAGE: end() END GPL. **************************************************. |
In reply to this post by uri1616
You can also add jitter by simply doing
SET RNG = MT MTINDEX = 54321. COMPUTE #jitter = RND.UNIFORM(0, 1). COMPUTE val = val + #jitter. * ... Gpl code. ------------------------------ On Fri, Oct 3, 2014 2:32 PM CEST Andy W wrote: >Here is an example reshaping the letter columns into one column using >VARSTOCASES and then using SPLIT FILE to create seperate charts for each >doc. > >**************************************************. >DATA LIST FREE / doc line A B C D E F G. >BEGIN DATA >182 330 3 0 0 0 0 0 0 >182 340 4 1 0 0 0 0 1 >182 350 5 3 0 0 0 0 2 >182 360 4 2 0 0 0 0 1 >182 370 5 1 0 0 0 0 1 >182 380 2 1 1 0 0 0 1 >183 380 2 3 3 1 0 1 0 >183 390 0 1 0 1 0 0 0 >183 400 3 3 0 1 0 0 1 >183 410 1 3 0 1 0 0 0 >183 420 0 0 0 0 0 0 0 >185 420 5 6 3 1 0 1 3 >185 430 1 6 3 1 0 1 2 >186 430 4 2 3 1 0 0 0 >186 440 3 5 3 1 0 0 1 >186 450 6 3 1 1 0 0 0 >186 460 5 1 1 0 0 0 1 >186 470 9 0 1 0 0 0 0 >186 480 0 0 0 0 0 0 0 >189 480 12 0 1 0 0 0 0 >189 490 6 0 0 0 0 0 0 >189 500 9 1 0 0 0 0 1 >189 510 11 0 2 0 0 0 0 >189 520 0 0 0 0 0 0 0 >196 520 1 0 0 0 0 0 0 >196 530 2 1 0 1 0 0 0 >196 540 0 1 0 0 1 0 0 >196 550 0 3 0 0 2 0 1 >196 560 0 2 0 0 1 0 0 >196 570 1 0 0 0 0 0 0 >196 580 0 0 0 0 0 0 0 >END DATA. >FORMATS ALL (F3.0). > >VARSTOCASES /MAKE Val FROM A TO G /INDEX Let (Val). > >*Split file for seperate charts. >SPLIT FILE BY doc. >GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES=line Val Let > /GRAPHSPEC SOURCE=INLINE. >BEGIN GPL > SOURCE: s=userSource(id("graphdataset")) > DATA: line=col(source(s), name("line")) > DATA: Val=col(source(s), name("Val")) > DATA: Let=col(source(s), name("Let"), unit.category()) > GUIDE: axis(dim(1), label("line")) > GUIDE: axis(dim(2), label("Val"), delta(1)) > GUIDE: legend(aesthetic(aesthetic.color.exterior)) > ELEMENT: point(position(line*Val), shape(Let)) >END GPL. >SPLIT FILE OFF. >**************************************************. > >Another option besides SPLIT FILE is to make a small multiple chart. > >**************************************************. >GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES=line Val Let doc > /GRAPHSPEC SOURCE=INLINE. >BEGIN GPL > PAGE: begin(scale(700px,700px)) > SOURCE: s=userSource(id("graphdataset")) > DATA: line=col(source(s), name("line")) > DATA: Val=col(source(s), name("Val")) > DATA: Let=col(source(s), name("Let"), unit.category()) > DATA: doc=col(source(s), name("doc"), unit.category()) > COORD: rect(dim(1,2), wrap()) > GUIDE: axis(dim(1), label("line")) > GUIDE: axis(dim(2), label("Val"), delta(1)) > GUIDE: axis(dim(3), opposite()) > ELEMENT: point(position(line*Val*doc), shape(Let)) > PAGE: end() >END GPL. >**************************************************. > >You will notice that these have a severe overlapping problem. One way I've >dealt with this in the past is to use jittering and/or semi-transparent >shapes. (See here for another example, >http://stats.stackexchange.com/a/19543/1036.) You may consider using a >sequential color scheme as well if the letters are intended to be ordinal >(e.g. A is dark and G is light). > >**************************************************. >GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES=line Val Let doc > /GRAPHSPEC SOURCE=INLINE. >BEGIN GPL > PAGE: begin(scale(700px,700px)) > SOURCE: s=userSource(id("graphdataset")) > DATA: line=col(source(s), name("line")) > DATA: Val=col(source(s), name("Val")) > DATA: Let=col(source(s), name("Let"), unit.category()) > DATA: doc=col(source(s), name("doc"), unit.category()) > COORD: rect(dim(1,2), wrap()) > GUIDE: axis(dim(1), label("line")) > GUIDE: axis(dim(2), label("Val"), delta(1)) > GUIDE: axis(dim(3), opposite()) > ELEMENT: point.dodge.symmetric(position(bin.rect.centroid(line*Val*doc, >dim(2), binWidth(1))), > transparency.exterior(transparency."0.3"), >transparency.interior(transparency."0.5"), > color.interior(Let), color.exterior(Let), shape(Let)) > PAGE: end() >END GPL. >**************************************************. > >In this circumstance just displaying the letters SPSS does a pretty good job >of displacing the labels > >**************************************************. >GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES=line Val Let doc > /GRAPHSPEC SOURCE=INLINE. >BEGIN GPL > PAGE: begin(scale(900px,600px)) > SOURCE: s=userSource(id("graphdataset")) > DATA: line=col(source(s), name("line")) > DATA: Val=col(source(s), name("Val")) > DATA: Let=col(source(s), name("Let"), unit.category()) > DATA: doc=col(source(s), name("doc"), unit.category()) > COORD: rect(dim(1,2), wrap()) > GUIDE: axis(dim(1), label("line")) > GUIDE: axis(dim(2), label("Val"), delta(1)) > GUIDE: axis(dim(3), opposite()) > ELEMENT: point(position(line*Val*doc), >transparency.exterior(transparency."1"), > label(Let, showAll())) > PAGE: end() >END GPL. >**************************************************. > ><http://spssx-discussion.1045642.n5.nabble.com/file/n5727487/Letters.png> > > > >----- >Andy W >[hidden email] >http://andrewpwheeler.wordpress.com/ >-- >View this message in context: http://spssx-discussion.1045642.n5.nabble.com/how-to-make-multiple-charts-out-of-one-dataset-tp5727473p5727487.html >Sent from the SPSSX Discussion mailing list archive at Nabble.com. > >===================== >To manage your subscription to SPSSX-L, send a message to >[hidden email] (not to SPSSX-L), with no body text except the >command. To leave the list, send the command >SIGNOFF SPSSX-L >For a list of commands to manage subscriptions, send the command >INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by Andy W
Complementing the suggestions by Andy, you could try a fluctuation type of graph:
GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=line Let Val /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: line=col(source(s), name("line")) DATA: Let=col(source(s), name("Let"), unit.category()) DATA: Val=col(source(s), name("Val")) SCALE: linear(aesthetic(aesthetic.size), aestheticMinimum(size."2px"), aestheticMaximum(size."25px")) SCALE: linear(dim(1), min(300), max(600)) GUIDE: axis(dim(1), label("line")) GUIDE: axis(dim(2), label("Let")) ELEMENT: point(position(line*Let), size(Val), color.interior(color.orange), transparency.interior(transparency."0.5") ) END GPL. (This is only the first graph in the run.) Here 'line' is considered a continuous variable if distances between pages is different and important; and the scaling is constant between documents. As the range of values is fairly small is is represented by the size of the point. Be careful when visualizing a linear scale with an area (as it increases by the square of the value) which may emphasize larger values. Semitransparent filling does not hide nearby points. It boils down to what the graph is supposed to convey to the reader... See https://andrewpwheeler.wordpress.com/2013/04/25/fluctuation-diagrams-in-spss/ for more inspiration! Greetings, PR |
In fact, Andy created a custom dialog box
for fluctuation plots (FluctuationChart.spd) that is available from the
SPSS Community website (www.ibm.com/developerworks/spssdevcentral)
> Downloads for SPSS Statistics in the SPSS Graphical Tools collection.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: PRogman <[hidden email]> To: [hidden email] Date: 10/04/2014 03:11 AM Subject: Re: [SPSSX-L] how to make multiple charts out of one dataset Sent by: "SPSSX(r) Discussion" <[hidden email]> Complementing the suggestions by Andy, you could try a fluctuation type of graph: (This is only the first graph in the run.) <http://spssx-discussion.1045642.n5.nabble.com/file/n5727492/SPSSgraph.png> Here 'line' is considered a continuous variable if distances between pages is different and important; and the scaling is constant between documents. As the range of values is fairly small is is represented by the size of the point. Be careful when visualizing a linear scale with an area (as it increases by the square of the value) which may emphasize larger values. Semitransparent filling does not hide nearby points. It boils down to what the graph is supposed to convey to the reader... See https://andrewpwheeler.wordpress.com/2013/04/25/fluctuation-diagrams-in-spss/ for more inspiration! Greetings, PR -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/how-to-make-multiple-charts-out-of-one-dataset-tp5727473p5727492.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Free forum by Nabble | Edit this page |