Separate axes in Chart Builder?

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

Separate axes in Chart Builder?

Robert L
Anyone who knows a way to set up two plots in the same chart where each has its own axis? It could be two dot plots, created in Chart Builder separated in two subgroups by use of the Groups/Point ID-Rows panel option? As an example, have la look at the following:

DATA LIST FREE /type(F1) measure(F3).
BEGIN DATA
1 120 1 121 1 129 1 119 1 120 2 10 2 11 2 9 2 10 2 11 2 12 2 11
END DATA.

DATASET NAME test_scales.

VARIABLE LEVEL type (NOMINAL) measure (SCALE).

* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=measure type MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: measure=col(source(s), name("measure"))
  DATA: type=col(source(s), name("type"), unit.category())
  COORD: rect(dim(1))
  GUIDE: axis(dim(1), label("measure"))
  GUIDE: axis(dim(3), label("type"), opposite())
  ELEMENT: point.dodge.asymmetric(position(bin.dot(measure*1*type)))
END GPL.

Fairly silly dotplots, the scale does not fit any of the groups. So would it be possible to use separate scales, while keeping the two dotplots in the same chart?

Robert

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

Re: Separate axes in Chart Builder?

Jignesh Sutar
I think when you panel charts in the way you are they, by default, the resulting charts are all on the same scale (in most cases this is desired).

But you can also manually panel, albeit not so easily, with GRAPH: BEGIN(ORIGIN, and in doing so can specify differing scales on axis.

(Not sure if you need to create dummy variables for Type1, Type2 or you can specify in the graph specification which codes to include...)


DATA LIST FREE /type(F1) measure(F3).
BEGIN DATA
1 120 1 121 1 129 1 119 1 120 2 10 2 11 2 9 2 10 2 11 2 12 2 11
END DATA.
DATASET NAME test_scales.
string type1 type2 (a5).
compute Type1="Type1".
compute Type2="Type2".
VARIABLE LEVEL type type1 type2 (NOMINAL) measure (SCALE).
sort cases by type measure.

* Chart Builder.
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=measure type1 type2 MISSING=variablewise REPORTMISSING=NO
/GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
GRAPH: begin(origin(10%, 10%), scale(80%, 37.5%))
  SOURCE: s=userSource(id("graphdataset"))
  DATA: measure=col(source(s), name("measure"))
  DATA: type1=col(source(s), name("type1"), unit.category())
  SCALE: linear(dim(1), min(110), max(130))
  GUIDE: axis(dim(1), label("measure"), opposite())
  GUIDE: axis(dim(2))
  GUIDE: axis(dim(2), opposite())
  ELEMENT: point.dodge(position((measure*type1)), color.interior(color.red))
GRAPH: end()
GRAPH: begin(origin(10%, 50%), scale(80%, 37.5%))
  SOURCE: s=userSource(id("graphdataset"))
  DATA: measure=col(source(s), name("measure"))
  DATA: type2=col(source(s), name("type2"), unit.category())
  SCALE: linear(dim(1), min(0), max(20))
  GUIDE: axis(dim(1), label("measure"))
  GUIDE: axis(dim(2))
  GUIDE: axis(dim(2), opposite())
  ELEMENT: point.dodge(position((measure*type2)), color.interior(color.green))
GRAPH: end()
END GPL.