CONTENTS DELETED
The author has deleted this message.
|
Here is an example using the employee data.sav
file shipped with the software. I generated the bar chart portion
by pasting from the Chart Builder. Then I added the other variable
to the VARIABLES part
mean(salbegin)[name="MEAN_salbegin"], the DATA statement for MEAN_salbegin, and the ELEMENT statement specifying a line. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=educ MEAN(salary)[name="MEAN_salary"] mean(salbegin)[name="MEAN_salbegin"] MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: educ=col(source(s), name("educ"), unit.category()) DATA: MEAN_salary=col(source(s), name("MEAN_salary")) DATA: MEAN_salbegin=col(source(s), name("MEAN_salbegin")) GUIDE: axis(dim(1), label("Educational Level (years)")) GUIDE: axis(dim(2), label("Mean Current Salary")) SCALE: cat(dim(1), include("8", "12", "14", "15", "16", "17", "18", "19", "20", "21")) SCALE: linear(dim(2), include(0)) ELEMENT: line(position(educ*MEAN_salbegin)) ELEMENT: interval(position(educ*MEAN_salary), shape.interior(shape.square)) END GPL. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: kalif <[hidden email]> To: [hidden email] Date: 02/23/2012 09:19 AM Subject: [SPSSX-L] How to put together two charts: bar and line Sent by: "SPSSX(r) Discussion" <[hidden email]> Hi, I have problem with stick together two charts. First of it is bar-chart that represent meassured valuse. I want to put there also background of measurment values as line chart in the background of bar-chart. In MS Office it was so easy, but there it is not. http://imageshack.us/photo/my-images/221/perz1caloscxx.png/ - the red line is that what i want to add to my charts (it's 3 charts connect in photoshop)... -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-put-together-two-charts-bar-and-line-tp5508322p5508322.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 |
Hi, This is an example of how something like this can be done with ggplot2 in R: http://imageshack.us/photo/my-images/215/samplegraph.png/ The code is below; you can use it inside a BEGIN-END PROGRAM R block, but you may need to download ggplot2 require(ggplot2) require(foreign) path <- "C:\\Program Files\\IBM\\SPSS\\Statistics\\19\\Samples\\English" df <- as.data.frame(read.spss(file.path(path, "Employee data.sav"))) df[, c("salary", "educ")] <- sapply(df[, c("salary", "educ")], as.numeric) df2 <- aggregate(df["salary"], df[c("gender", "educ", "jobcat")], mean, na.rm=TRUE) p <- ggplot(df2) + geom_bar(stat="identity", aes(x=educ, y=salary, fill=jobcat)) + geom_line(stat="identity", aes(x=educ, y=salary), colour="red", size=1, alpha=0.5) + coord_flip() + facet_grid(gender~.) + opts(title="Mean salary by education and job category\n") ggsave(file.path(Sys.getenv("temp"), "sample_graph.png"), p, scale=2) Cheers!! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: Albert-Jan Roskam <[hidden email]> To: Jon K Peck/Chicago/IBM@IBMUS, "[hidden email]" <[hidden email]> Date: 02/25/2012 01:16 PM Subject: Re: [SPSSX-L] How to put together two charts: bar and line Hi, This is an example of how something like this can be done with ggplot2 in R: >>>which is a lot like the Statistics GPL solution I posted, perhaps because ggplot2 is actually based on GPL. -Jon Peck http://imageshack.us/photo/my-images/215/samplegraph.png/ The code is below; you can use it inside a BEGIN-END PROGRAM R block, but you may need to download ggplot2 require(ggplot2) require(foreign) path <- "C:\\Program Files\\IBM\\SPSS\\Statistics\\19\\Samples\\English" df <- as.data.frame(read.spss(file.path(path, "Employee data.sav"))) df[, c("salary", "educ")] <- sapply(df[, c("salary", "educ")], as.numeric) df2 <- aggregate(df["salary"], df[c("gender", "educ", "jobcat")], mean, na.rm=TRUE) p <- ggplot(df2) + geom_bar(stat="identity", aes(x=educ, y=salary, fill=jobcat)) + geom_line(stat="identity", aes(x=educ, y=salary), colour="red", size=1, alpha=0.5) + coord_flip() + facet_grid(gender~.) + opts(title="Mean salary by education and job category\n") ggsave(file.path(Sys.getenv("temp"), "sample_graph.png"), p, scale=2) Cheers!! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From: Jon K Peck <[hidden email]> To: [hidden email] Sent: Thursday, February 23, 2012 5:53 PM Subject: Re: [SPSSX-L] How to put together two charts: bar and line Here is an example using the employee data.sav file shipped with the software. I generated the bar chart portion by pasting from the Chart Builder. Then I added the other variable to the VARIABLES part mean(salbegin)[name="MEAN_salbegin"], the DATA statement for MEAN_salbegin, and the ELEMENT statement specifying a line. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=educ MEAN(salary)[name="MEAN_salary"] mean(salbegin)[name="MEAN_salbegin"] MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: educ=col(source(s), name("educ"), unit.category()) DATA: MEAN_salary=col(source(s), name("MEAN_salary")) DATA: MEAN_salbegin=col(source(s), name("MEAN_salbegin")) GUIDE: axis(dim(1), label("Educational Level (years)")) GUIDE: axis(dim(2), label("Mean Current Salary")) SCALE: cat(dim(1), include("8", "12", "14", "15", "16", "17", "18", "19", "20", "21")) SCALE: linear(dim(2), include(0)) ELEMENT: line(position(educ*MEAN_salbegin)) ELEMENT: interval(position(educ*MEAN_salary), shape.interior(shape.square)) END GPL. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: kalif <[hidden email]> To: [hidden email] Date: 02/23/2012 09:19 AM Subject: [SPSSX-L] How to put together two charts: bar and line Sent by: "SPSSX(r) Discussion" <[hidden email]> Hi, I have problem with stick together two charts. First of it is bar-chart that represent meassured valuse. I want to put there also background of measurment values as line chart in the background of bar-chart. In MS Office it was so easy, but there it is not. http://imageshack.us/photo/my-images/221/perz1caloscxx.png/ - the red line is that what i want to add to my charts (it's 3 charts connect in photoshop)... -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-put-together-two-charts-bar-and-line-tp5508322p5508322.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 |
Is Wilkinson's Grammar of Graphics an open 'standard'? Was it never a problem for Spss that the exact same idea was applied in R's ggplot2? Cheers!! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Free forum by Nabble | Edit this page |