Changing axis on graph (Not GPL) & merging panels

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

Changing axis on graph (Not GPL) & merging panels

ecottrell
This post was updated on .
Hello!

I'm working with the following syntax:

GRAPH
  /LINE(MULTIPLE)=MEAN(DRS_Score) BY data_point BY PRE_LTCH
  /PANEL ROWVAR=Sex_AA2 ROWOP=CROSS.

I'm trying to figure out how I can change the axis so it's the full scale of
the measure (for example DRS_Score is 0-14 but because the means are under 4
it shows me a 0-4 scale).

The issue is I can't use GPL (I don't think) because I want to make it a
macro to run through all my variables (and I don't know python at all), and
I also don't think I can use graph templates because each variable has a
different scale.

I'm also wondering if there's a way to merge panels (so female and male are
shown on the same graph not side by side).

Thank you so much for any help!



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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
Reply | Threaded
Open this post in threaded view
|

Re: Changing axis on graph (Not GLM) & merging panels

Jon Peck
You need to use GGRAPH (Chartbuilder).  It, via GPL, lets you specify the axis range.  It also addresses your second issue by providing a population pyramid chart type.

On Sun, Sep 8, 2019 at 10:14 PM ecottrell <[hidden email]> wrote:
Hello!

I'm working with the following syntax:

GRAPH
  /LINE(MULTIPLE)=MEAN(DRS_Score) BY data_point BY PRE_LTCH
  /PANEL ROWVAR=Sex_AA2 ROWOP=CROSS.

I'm trying to figure out how I can change the axis so it's the full scale of
the measure (for example DRS_Score is 0-14 but because the means are under 4
it shows me a 0-4 scale).

The issue is I can't use GLM (I don't think) because I want to make it a
macro to run through all my variables (and I don't know python at all), and
I also don't think I can use graph templates because each variable has a
different scale.

I'm also wondering if there's a way to merge panels (so female and male are
shown on the same graph not side by side).

Thank you so much for any help!



--
Sent from: http://spssx-discussion.1045642.n5.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
--
Jon K Peck
[hidden email]

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Changing axis on graph (Not GLM) & merging panels

ecottrell
I realized in my initial post I accidentally wrote GLM when I meant GPL.
That's what I get for multitasking. I've fixed it.

The issue (as far as I can find) with GGraph and GPL is that it don't allow
you to create macros using them without using python.




Jon Peck wrote
> You need to use GGRAPH (Chartbuilder).  It, via GPL, lets you specify the
> axis range.  It also addresses your second issue by providing a population
> pyramid chart type.
>
> On Sun, Sep 8, 2019 at 10:14 PM ecottrell &lt;

> ecottrell@

> &gt; wrote:
>
>> Hello!
>>
>> I'm working with the following syntax:
>>
>> GRAPH
>>   /LINE(MULTIPLE)=MEAN(DRS_Score) BY data_point BY PRE_LTCH
>>   /PANEL ROWVAR=Sex_AA2 ROWOP=CROSS.
>>
>> I'm trying to figure out how I can change the axis so it's the full scale
>> of
>> the measure (for example DRS_Score is 0-14 but because the means are
>> under
>> 4
>> it shows me a 0-4 scale).
>>
>> The issue is I can't use GLM (I don't think) because I want to make it a
>> macro to run through all my variables (and I don't know python at all),
>> and
>> I also don't think I can use graph templates because each variable has a
>> different scale.
>>
>> I'm also wondering if there's a way to merge panels (so female and male
>> are
>> shown on the same graph not side by side).
>>
>> Thank you so much for any help!
>>
>>
>>
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

>  (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
>>
> --
> Jon K Peck

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





--
Sent from: http://spssx-discussion.1045642.n5.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
Reply | Threaded
Open this post in threaded view
|

Re: Changing axis on graph (Not GLM) & merging panels

Bruce Weaver
Administrator
In case others are wondering what ecottrell is talking about, here is an old
thread in which ViAnn Beadle explains why GPL does not work well inside
macros:

http://spssx-discussion.1045642.n5.nabble.com/Automating-GPL-code-td4425452.html#a4425526

I have dim memories of running into this problem myself several years ago,
and imagine there are a few of my own posts about it in the archives.  

If you provide a small sample dataset (via DATA LIST), perhaps one of the
Pythonistas in the group would be willing to write a small program for you
that you could modify as needed.  

HTH.




ecottrell wrote

> I realized in my initial post I accidentally wrote GLM when I meant GPL.
> That's what I get for multitasking. I've fixed it.
>
> The issue (as far as I can find) with GGraph and GPL is that it don't
> allow
> you to create macros using them without using python.
>
>
>
>
> Jon Peck wrote
>> You need to use GGRAPH (Chartbuilder).  It, via GPL, lets you specify the
>> axis range.  It also addresses your second issue by providing a
>> population
>> pyramid chart type.
>>
>> On Sun, Sep 8, 2019 at 10:14 PM ecottrell &lt;
>
>> ecottrell@
>
>> &gt; wrote:
>>
>>> Hello!
>>>
>>> I'm working with the following syntax:
>>>
>>> GRAPH
>>>   /LINE(MULTIPLE)=MEAN(DRS_Score) BY data_point BY PRE_LTCH
>>>   /PANEL ROWVAR=Sex_AA2 ROWOP=CROSS.
>>>
>>> I'm trying to figure out how I can change the axis so it's the full
>>> scale
>>> of
>>> the measure (for example DRS_Score is 0-14 but because the means are
>>> under
>>> 4
>>> it shows me a 0-4 scale).
>>>
>>> The issue is I can't use GLM (I don't think) because I want to make it a
>>> macro to run through all my variables (and I don't know python at all),
>>> and
>>> I also don't think I can use graph templates because each variable has a
>>> different scale.
>>>
>>> I'm also wondering if there's a way to merge panels (so female and male
>>> are
>>> shown on the same graph not side by side).
>>>
>>> Thank you so much for any help!
>>>
>>>
>>>
>>> --
>>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>>
>>> =====================
>>> To manage your subscription to SPSSX-L, send a message to
>>>
>
>> LISTSERV@.UGA
>
>>  (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
>>>
>> --
>> Jon K Peck
>
>> jkpeck@
>
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (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
>
>
>
>
>
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Changing axis on graph (Not GLM) & merging panels

Jon Peck
In reply to this post by ecottrell
I wondered why GLM came up here :-).  Also, if each variable has a different upper bound, that would make the upper bound a parameter, right?

Parameterizing the variable name and upper bound with a little Python wrapper around the GGRAPH/GPL code would be easy.  If you want to provide your proposed GGRAPH and GPL code, I can write that for  you.





On Mon, Sep 9, 2019 at 4:16 PM ecottrell <[hidden email]> wrote:
I realized in my initial post I accidentally wrote GLM when I meant GPL.
That's what I get for multitasking. I've fixed it.

The issue (as far as I can find) with GGraph and GPL is that it don't allow
you to create macros using them without using python.




Jon Peck wrote
> You need to use GGRAPH (Chartbuilder).  It, via GPL, lets you specify the
> axis range.  It also addresses your second issue by providing a population
> pyramid chart type.
>
> On Sun, Sep 8, 2019 at 10:14 PM ecottrell &lt;

> ecottrell@

> &gt; wrote:
>
>> Hello!
>>
>> I'm working with the following syntax:
>>
>> GRAPH
>>   /LINE(MULTIPLE)=MEAN(DRS_Score) BY data_point BY PRE_LTCH
>>   /PANEL ROWVAR=Sex_AA2 ROWOP=CROSS.
>>
>> I'm trying to figure out how I can change the axis so it's the full scale
>> of
>> the measure (for example DRS_Score is 0-14 but because the means are
>> under
>> 4
>> it shows me a 0-4 scale).
>>
>> The issue is I can't use GLM (I don't think) because I want to make it a
>> macro to run through all my variables (and I don't know python at all),
>> and
>> I also don't think I can use graph templates because each variable has a
>> different scale.
>>
>> I'm also wondering if there's a way to merge panels (so female and male
>> are
>> shown on the same graph not side by side).
>>
>> Thank you so much for any help!
>>
>>
>>
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

>  (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
>>
> --
> Jon K Peck

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Changing axis on graph (Not GLM) & merging panels

ecottrell
I created a variable that solved the panel merging issue I was having.

Each variable does have a different upper bound:

The variables are:  
DRS_Score
CHESS_Score
PAIN_Score
ADL_H_SCORE
ADL_S_SCORE
ADL_L_SCORE
ISE_SCORE
PSI_SCORE
ABS_SCORE
PURS_SCORE
CPS_SCORE

The upper bound/what I want the axis to go to for each, in order of the
above variables, are:
14
5
3
6
16
28
6
18
12
8
6

This is my GGRAPH code, using my first variable DRS_Score:
(I'm not overly concerned about titles at this point.)

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=data_point
MEAN(DRS_Score)[name="MEAN_DRS_Score"]
    Interact MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: data_point=col(source(s), name("data_point"), unit.category())
  DATA: MEAN_DRS_Score=col(source(s), name("MEAN_DRS_Score"))
  DATA: Interact=col(source(s), name("Interact"),
notIn("0"), unit.category())
  GUIDE: axis(dim(1), label("Data Point"))
  GUIDE: axis(dim(2), delta(1), label("Mean Depression Rating Scale
(0-14)"))
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("Interaction of
Sex and Pre-LTCH"))
  SCALE: cat(dim(1), include("1", "2", "3", "4"))
  SCALE: linear(dim(2), min(0), max(14))
  SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2", "3",
"4", "5", "6"))
  ELEMENT: line(position(data_point*MEAN_DRS_Score),
color.interior(Interact), missing.wings())
END GPL.

Thank you so much for your help I really appreciate it!



--
Sent from: http://spssx-discussion.1045642.n5.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
Reply | Threaded
Open this post in threaded view
|

Re: Changing axis on graph (Not GLM) & merging panels

ecottrell
In reply to this post by Jon Peck
So I've been playing around with Python (It's not as terrifying as I thought
it would be) and I'm trying to just get it to work for my main variables
(not the axis yet) but my graphs don't have lines so I'm not sure what I'm
doing wrong.

<http://spssx-discussion.1045642.n5.nabble.com/file/t341620/OUTPUT.png>


Here's my code:

begin program.
import spss
varList = ['DRS_Score' , 'CHESS_Score' , 'PAIN_Score' , 'ADL_H_Score' ,
'ADL_S_Score']
print varList
end program.

begin program.
for var in varList:
    spss.Submit('''
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=data_point
MEAN(%s)[name="MEAN_score"]
    Interact MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: data_point=col(source(s), name("data_point"), unit.category())
  DATA: MEAN_score=col(source(s), name("MEAN"))
  DATA: Interact=col(source(s), name("Interact"),
notIn("0"), unit.category())
  GUIDE: axis(dim(1), label("Data Point"))
  GUIDE: axis(dim(2), delta(1), label("Mean"))
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("Interaction of
Sex and Pre-LTCH"))
  SCALE: cat(dim(1), include("1", "2", "3", "4"))
  SCALE: linear(dim(2), min(0), max(14))
  SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2", "3",
"4", "5", "6"))
  ELEMENT: line(position(data_point*MEAN_score), color.interior(Interact),
missing.wings())
END GPL..
'''%(var))
end program.





--
Sent from: http://spssx-discussion.1045642.n5.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
Reply | Threaded
Open this post in threaded view
|

Re: Changing axis on graph (Not GLM) & merging panels

Jon Peck
I can't guess what the issue might be - it could be data related, but you can separate Python issues from GGRAH/GPL issues by looking at the code in the Notes table for your charts.  The Python code that generated the regular syntax will be out of the picture there.

On Tue, Sep 10, 2019 at 4:52 PM ecottrell <[hidden email]> wrote:
So I've been playing around with Python (It's not as terrifying as I thought
it would be) and I'm trying to just get it to work for my main variables
(not the axis yet) but my graphs don't have lines so I'm not sure what I'm
doing wrong.

<http://spssx-discussion.1045642.n5.nabble.com/file/t341620/OUTPUT.png>


Here's my code:

begin program.
import spss
varList = ['DRS_Score' , 'CHESS_Score' , 'PAIN_Score' , 'ADL_H_Score' ,
'ADL_S_Score']
print varList
end program.

begin program.
for var in varList:
    spss.Submit('''
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=data_point
MEAN(%s)[name="MEAN_score"]
    Interact MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: data_point=col(source(s), name("data_point"), unit.category())
  DATA: MEAN_score=col(source(s), name("MEAN"))
  DATA: Interact=col(source(s), name("Interact"),
notIn("0"), unit.category())
  GUIDE: axis(dim(1), label("Data Point"))
  GUIDE: axis(dim(2), delta(1), label("Mean"))
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("Interaction of
Sex and Pre-LTCH"))
  SCALE: cat(dim(1), include("1", "2", "3", "4"))
  SCALE: linear(dim(2), min(0), max(14))
  SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2", "3",
"4", "5", "6"))
  ELEMENT: line(position(data_point*MEAN_score), color.interior(Interact),
missing.wings())
END GPL..
'''%(var))
end program.





--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Changing axis on graph (Not GLM) & merging panels

Bruce Weaver
Administrator
In reply to this post by Bruce Weaver
For the record, here is the old post I was dimly remembering.  It was posted
to the usenet forum comp.soft-sys.stat.spss, not to this mailing list.  

https://groups.google.com/d/msg/comp.soft-sys.stat.spss/6qezsBB13Wk/iZzAiQCOfqIJ



Bruce Weaver wrote

> In case others are wondering what ecottrell is talking about, here is an
> old
> thread in which ViAnn Beadle explains why GPL does not work well inside
> macros:
>
> http://spssx-discussion.1045642.n5.nabble.com/Automating-GPL-code-td4425452.html#a4425526
>
> I have dim memories of running into this problem myself several years ago,
> and imagine there are a few of my own posts about it in the archives.  
>
> If you provide a small sample dataset (via DATA LIST), perhaps one of the
> Pythonistas in the group would be willing to write a small program for you
> that you could modify as needed.  
>
> HTH.





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).