Adding Vertial Line in chart

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding Vertial Line in chart

Gad Chen

Dear

 

Hi, everyone,

 

I want to add two vertical line in the histogram chart to show where are 20 Percentile and 80 Percentile.

 

Is there any way to do it using syntax instead of doing it manually? I am using version 18.

 

Thanks a lot !

 

Gad

 

SET seed=943997.

 

input program.

loop a =1 to 100 by 1.

end case.

end loop.

end file.

end input program.

 

compute x = NORMAL(0.25).

***EXECUTE.

 

FREQUENCIES VARIABLES=x

  /FORMAT=NOTABLE

  /PERCENTILES=20.0 80.0

  /HISTOGRAM NORMAL

  /ORDER=ANALYSIS.

 

 

Reply | Threaded
Open this post in threaded view
|

Automatic reply: Adding Vertial Line in chart

MacGillivary Heather L

I am out of the office until Tuesday September 4th and will reply to emails at that time. 

If you need immediate assistance, please contact Kay Gates 303-982-6565 or [hidden email]

Heather

 

Reply | Threaded
Open this post in threaded view
|

Automatic reply: Adding Vertial Line in chart

Jenenne Geske
In reply to this post by Gad Chen

I will be out of the office until Tuesday, September 4. I will respond to your e-mail as soon as possible on my return.

Reply | Threaded
Open this post in threaded view
|

Re: Adding Vertial Line in chart

Albert-Jan Roskam
In reply to this post by Gad Chen
Hello,
 
If you use the R plugin, you could use ggplot2:
 
require(ggplot2)
df <- data.frame(x=round(runif(1000, 0, 10))) # replace with your own data
p <- ggplot(df, aes(x=x)) + geom_histogram() + geom_vline(xintercept=c(2, 8), colour="red")
ggsave("d:/temp/graph.png", p)
p
 
Regards,
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: Gad <[hidden email]>
To: [hidden email]
Sent: Friday, August 31, 2012 2:03 AM
Subject: [SPSSX-L] Adding Vertial Line in chart

Dear
 
Hi, everyone,
 
I want to add two vertical line in the histogram chart to show where are 20 Percentile and 80 Percentile.
 
Is there any way to do it using syntax instead of doing it manually? I am using version 18.
 
Thanks a lot !
 
Gad
 
SET seed=943997.
 
input program.
loop a =1 to 100 by 1.
end case.
end loop.
end file.
end input program.
 
compute x = NORMAL(0.25).
***EXECUTE.
 
FREQUENCIES VARIABLES=x
  /FORMAT=NOTABLE
  /PERCENTILES=20.0 80.0
  /HISTOGRAM NORMAL
  /ORDER=ANALYSIS.
 
 


Reply | Threaded
Open this post in threaded view
|

Automatic reply: Adding Vertial Line in chart

Tierney, Mary Lou

I am PTOB today, Friday 31 August.

 

For assistance with the MITRE Innovation Program please contact the [hidden email]

 

For assistance with Project/Portfolio Pages or Discover, please contact the [hidden email]

 

For assistance with other Innovation Zone sites, such as CI&T InZone, please contact [hidden email].

 

 

Regards,

Mary Lou

Reply | Threaded
Open this post in threaded view
|

Re: Adding Vertial Line in chart

Andy W
In reply to this post by Gad Chen

If you know where to specify the lines you can use GUIDE: form.line commands in GGRAPH to insert guide lines. Example below with your data.


*************************************************************.
SET seed=943997.
input program.
loop a =1 to 100 by 1.
end case.
end loop.
end file.
end input program.
compute x = NORMAL(0.25).
exe.

freq var x /format = notable /PERCENTILES=20 80.
*for these random numbers percentiles are at [-.230] and [.197].
 
* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=x MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: x=col(source(s), name("x"))
  GUIDE: axis(dim(1), label("x"))
  GUIDE: axis(dim(2), label("Frequency"))
  ELEMENT: interval(position(summary.count(bin.rect(x))), shape.interior(shape.square), transparency.interior(transparency."0.5"))
  GUIDE: form.line(position(-.230), color(color.red), size(size."3"))
  GUIDE: form.line(position(.197), color(color.blue), size(size."3"))
END GPL.
*************************************************************.

I briefly tried to make the percentiles via summary functions (i.e. GPTILE(x,20) in the GRAPHDATASET command) but was unsuccessful. Maybe some more of the guru's can come along and give an example. Another option would be just to make an actual value in your dataset that corresponds to the 20th and 80th percentile and include it in the plot, but if it is possible directly within GGRAPH statements it will be much less work.

Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Adding Vertial Line in chart

Andy W

Oh boy here come another dozen out of office replies.

Playing around some more I figured out at least one way to do it directly within GGRAPH statments. I've had problems in the past before specifying varying "N" graphical summaries within the same GRAPHDATASET command, so I tried the summary functions I was talking about before but piping them to seperate GRAPHDATASETS. Below is an example.


*************************************************************.
SET seed=943997.
input program.
loop a =1 to 100 by 1.
end case.
end loop.
end file.
end input program.
dataset name sim.
compute x = NORMAL(0.25).
exe.

GGRAPH
  /GRAPHDATASET NAME="fulldata" DATASET = 'sim' VARIABLES=x
  /GRAPHDATASET NAME="sumdata" DATASET = 'sim' VARIABLES = GPTILE(x, 80)[NAME = "Per80"]  GPTILE(x, 20)[NAME = "Per20"]  
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: fulldata=userSource(id("fulldata"))
  DATA: x=col(source(fulldata), name("x"))
  SOURCE: sumdata=userSource(id("sumdata"))
  DATA: Per80=col(source(sumdata), name("Per80"))
  DATA: Per20=col(source(sumdata), name("Per20"))
  TRANS: top = eval(25)
  GUIDE: axis(dim(1), label("x"))
  GUIDE: axis(dim(2), label("Frequency"))
  SCALE: linear(dim(2), min(0), max(20))
  ELEMENT: interval(position(summary.count(bin.rect(x))), shape.interior(shape.square), transparency.interior(transparency."0.5"))
  ELEMENT: interval(position(Per80*top), color(color.red), size(size."3"))
  ELEMENT: interval(position(Per20*top), color(color.blue), size(size."3"))
END GPL.

I realize reading and parsing GGRAPH statements isn't the most pleasant. If you have any questions let me know.

Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Adding Vertical Line in chart

Jon K Peck
This text from the CSR might clarify the problems you have had with graphical summaries.

When the variable specification includes an aggregation function and does not include the
CASEVALUE function, the graph dataset is aggregated. Any stand-alone variables in the variable
specification act as categorical break variables for the aggregation (including scale variables that
are not parameters of a summary function). The function is evaluated for each unique value in
each break variable. When the variable specification includes only variables or includes the
CASEVALUE function, the graph dataset is unaggregated. The built-in variable $CASENUM is
included in the unaggregated dataset. $CASENUM cannot be specified or renamed in the variable
specification, but you can refer to it in the graph specification.

An unaggregated graph dataset includes a case for every case in the IBM® SPSS® Statistics
dataset. An aggregated dataset includes a case for every combination of unique break variable
values. For example, assume that there are two categorical variables that act as break variables. If
there are three categories in one variable and two in the other, there are six cases in the aggregated
graph dataset, as long as there are values for each category.

Note: If the dataset is aggregated, be sure to include all of the break variables in the graph
specification (the ViZml or GPL). For example, if the variable specification includes two
categorical variables and a summary function of a scale variable, the graph specification should
use one of the categorical variables as the x-axis variable and one as a grouping or panel variable.
Otherwise, the resulting graph will not be correct because it does not contain all of the information
used for the aggregation.

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Andy W <[hidden email]>
To:        [hidden email]
Date:        08/31/2012 06:47 AM
Subject:        Re: [SPSSX-L] Adding Vertial Line in chart
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Oh boy here come another dozen out of office replies.

Playing around some more I figured out at least one way to do it directly within GGRAPH statments. I've had problems in the past before specifying varying "N" graphical summaries within the same GRAPHDATASET command, so I tried the summary functions I was talking about before but piping them to seperate GRAPHDATASETS. Below is an example.


*************************************************************.
SET seed=943997.
input program.
loop a =1 to 100 by 1.
end case.
end loop.
end file.
end input program.
dataset name sim.
compute x = NORMAL(0.25).
exe.

GGRAPH
 /GRAPHDATASET NAME="fulldata" DATASET = 'sim' VARIABLES=x
 /GRAPHDATASET NAME="sumdata" DATASET = 'sim' VARIABLES = GPTILE(x, 80)[NAME = "Per80"]  GPTILE(x, 20)[NAME = "Per20"]
 /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: fulldata=userSource(id("fulldata"))
 DATA: x=col(source(fulldata), name("x"))
 SOURCE: sumdata=userSource(id("sumdata"))
 DATA: Per80=col(source(sumdata), name("Per80"))
 DATA: Per20=col(source(sumdata), name("Per20"))
 TRANS: top = eval(25)
 GUIDE: axis(dim(1), label("x"))
 GUIDE: axis(dim(2), label("Frequency"))
 SCALE: linear(dim(2), min(0), max(20))
 ELEMENT: interval(position(summary.count(bin.rect(x))), shape.interior(shape.square), transparency.interior(transparency."0.5"))
 ELEMENT: interval(position(Per80*top), color(color.red), size(size."3"))
 ELEMENT: interval(position(Per20*top), color(color.blue), size(size."3"))
END GPL.

I realize reading and parsing GGRAPH statements isn't the most pleasant. If you have any questions let me know.

Andy W
[hidden email]

http://andrewpwheeler.wordpress.com/



View this message in context: Re: Adding Vertial Line in chart
Sent from the
SPSSX Discussion mailing list archive at Nabble.com.