Data visualization with SAS programming

Using the Origin= Option in an Axis Statement

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Using the Origin= Option in an Axis Statement

Hi all,

Haven't been able to find any posts about other people having problems with this option, but it never seems to work for me. After debugging a good graph, I try to move the position of the plot area within the graph area by using the origin option on one or both axes. Complete crash-and-burn. I am using 9.3 64-bit with Windows 7 Professional, but I've had this problem since at least 8.2.

Consider this code. The setup is much the way I normally use it, but the same problem crops up with HTML and a single, simple graph.

data gimmee;

    do x = 1 to 10;

        do y = 5 to 50;

            output;

        end;

    end;

    run;

ods pdf  file='c:\Time to Ask.pdf'

         notoc

         startpage=never;

    options  orientation=landscape  papersize=letter pdfpageview=actual;

    options  linesize=148           nonumber nodate;

    goptions  reset = all;

    * Full-page titles;

    goptions  hsize=10in  vsize=8in;

    title1 'Time to Ask for Help!';

    title2 'Case 2 with Origin Option';

        proc gslide;

            run;

            quit;

    * Individual graphs;

    goptions  hsize=2.5in  vsize=2.5in;

    title;

    axis1 label=('X-axis')  order=(1 to 10 by  1); *  origin=(.25in, .25in);

    axis2 label=('Y')       order=(5 to 50 by 10); * origin=(.25in, .25in);

        goptions  horigin = 0in vorigin= 0in;    proc gplot  data=gimmee;  plot y * x / haxis=axis1 vaxis=axis2;  run;  quit;

        goptions  horigin = 5in vorigin= 0in;    proc gplot  data=gimmee;  plot y * x / haxis=axis1 vaxis=axis2;  run;  quit;

        goptions  horigin = 0in vorigin=3.5in;   proc gplot  data=gimmee;  plot y * x / haxis=axis1 vaxis=axis2;  run;  quit;

        goptions  horigin = 5in vorigin=3.5in;   proc gplot  data=gimmee;  plot y * x / haxis=axis1 vaxis=axis2;  run;  quit;

ods pdf  close;

Case #1 is run as-is and works perfectly.

Case #2 is run after removing either or both of the comments at the end of the axis statements. The run fails completely with the message, "WARNING: Graph has missing data for the required role ( y * x ), no graph will be produced.".

What am I missing?

Thanks. This is a great service.


Accepted Solutions
Solution
‎04-03-2014 01:50 PM
Grand Advisor
Posts: 9,748

Re: Using the Origin= Option in an Axis Statement

I would expect failure with 1pct 1pt and likely 1cell as axis text needs to display label and values. Which is at least 2 cells and almost guaranteed to be more than 1pt. The shift of the orgin within the graph display to that close to the left/bottom area isn't leaving room for text. With a graph size of 2.5x2.5 inches 1pct means 0.025 inches, which also won't allow any space for actual text.

I ran some of this code and get error messages like;

 

ERROR: The specified y-origin for the bottom horizontal axis labeled x did not leave enough space

for the text. You need to specify ORIGIN=( , 8.6 PERCENT ). The graph was not produced.

So that says exactly what the smallest value would work with the current settings.

Also, why in your examples are you changeing the Goptions for horigin and vorigin? That just complicates figuring out what the axis statments are doing.

View solution in original post


All Replies
Grand Advisor
Posts: 9,748

Re: Using the Origin= Option in an Axis Statement

I stripped your code to bare bones and got error messages that there wasn't enough space to display the axis text, i.e. values and default label within the space specified. Your .25in says to move the axis to within that much space of the left and bottom borders and the default font sizes are likely to want more space. You may also be having issues with the startpage option. The following code admittedly without all of your goptions does shift the seocnd graph within graph display area. I'd start with something like this and then add in options one at a time to see what happens.

axis1 label=('X-axis')  order=(1 to 10 by  1);  *  origin=(.25in, .25in);
axis2 label=('Y')       order=(5 to 50 by  10); ; * origin=(.25in, .25in);
axis3 label=('X-axis')   order=(1 to 10 by  1) origin=(, 1in);
axis4 label=('Y')       order=(5 to 50 by  10) origin=(1in,);

ods listing close;
ods pdf file='d:\data\junk.pdf' style=meadow ;
proc gplot  data=gimmee; 
plot y * x / haxis=axis1 vaxis=axis2;  run;
plot y * x / haxis=axis3 vaxis=axis4;  run;
quit;
ods pdf close;
ods listing;

Occasional Contributor
Posts: 6

Re: Using the Origin= Option in an Axis Statement

Hi Ballard,

Thanks for the reply. Your code works fine, and when I modified my original code to use integers for the origin it also worked fine. The moment I move to a non-integer like my original .25in it fails. This is progress! Smiley Happy but unfortunately does not allow for fine control.

The allowed units for origin are cell, cm, in, pct, or pt. However, the only one that seems to work is "in" and that just for integers. In the following code only the graph in inches (title "In") is produced. The other graphs produce the old error message, "WARNING: Graph has missing data for the required role ( y * x ), no graph will be produced.".

Is this the intended behavior? Seems counter-intuitive and is not documented in Online Docs.

ods pdf  file='c:\Time to Ask.pdf'

         notoc

         startpage=never;

    options  orientation=landscape  papersize=letter pdfpageview=actual;

    options  linesize=148           nonumber nodate;

    goptions  reset = all;

    * Full-page titles;

    goptions  hsize=10in  vsize=8in;

    title1 'Time to Ask for Help!';

    title2 'Case 2 with Origin Option';

        proc gslide;

            run;

            quit;

    * Individual graphs;

    goptions  hsize=2.5in  vsize=2.5in;

    title;

    axis11 label=('X-axis')  order=(1 to 10 by  1)  origin=(1pct, 1pct);

    axis12 label=('Y')       order=(5 to 50 by 10)  origin=(1pct, 1pct);

    axis21 label=('X-axis')  order=(1 to 10 by  1)  origin=(1in,  1in);

    axis22 label=('Y')       order=(5 to 50 by 10)  origin=(1in,  1in);

    axis31 label=('X-axis')  order=(1 to 10 by  1)  origin=(1cm,  1cm);

    axis32 label=('Y')       order=(5 to 50 by 10)  origin=(1cm,  1cm);

    axis41 label=('X-axis')  order=(1 to 10 by  1)  origin=(1pt,  1pt);

    axis42 label=('Y')       order=(5 to 50 by 10)  origin=(1pt,  1pt);

    axis51 label=('X-axis')  order=(1 to 10 by  1)  origin=(1cells,  1cells);

    axis52 label=('Y')       order=(5 to 50 by 10)  origin=(1cells,  1cells);

        goptions  horigin = 0in   vorigin= 0in;   title 'Pct';  proc gplot  data=gimmee;  plot y * x / haxis=axis11 vaxis=axis12;  run;  quit;

        goptions  horigin = 2.5in vorigin= 0in;   title 'In';   proc gplot  data=gimmee;  plot y * x / haxis=axis21 vaxis=axis22;  run;  quit;

        goptions  horigin = 5.0in vorigin= 0in;   title 'Cm';   proc gplot  data=gimmee;  plot y * x / haxis=axis31 vaxis=axis32;  run;  quit;

        goptions  horigin = 7.5in vorigin= 0in;   title 'Pt';   proc gplot  data=gimmee;  plot y * x / haxis=axis41 vaxis=axis42;  run;  quit;

        goptions  horigin = 0in   vorigin=2.5in;  title 'Cells';proc gplot  data=gimmee;  plot y * x / haxis=axis41 vaxis=axis42;  run;  quit;

ods pdf  close;

Super Contributor
Posts: 273

Re: Using the Origin= Option in an Axis Statement

LHerr

Years ago this kind of code was working   with the use of  decimal indication for centimeters

i was using vsize and hsize in place of origin...

HTH

Andre

4 maps on a page   plus a title through gslide

ods listing close;

goptions reset=all vsize=21 cm hsize=18 cm ;options papersize=a4;

ods pdf file="d:\temp\fe.pdf"   startpage=never;

goptions vsize=0 cm hsize=0 cm devmap=winansi keymap=winansi ftitle="helvetica/bold";

ods proclabel 'age médian';

proc gslide gout=sasuser.hert;

title1 h=0.5 cm J=c  "Figure1.";

title2 h=0.4 cm  f="helvetica/bold" j=c  " Age Médian au premier mariage des femmes par période.";

title4 h=0.3 cm  f="Helvetica/oblique" j=c "(les sources sont précisées en annexe 2)";

run;quit;

   pattern1 v=s c=cxFFFF00;

   pattern2 v=s c=cxffb000;

   pattern3 v=s c=cxff7000;

   pattern4 v=s c=cxff1000;

   pattern5 v=s c=white;

goptions hsize=8.6 cm vsize=9.2 cm target=jpeg devmap=winansi keymap=winansi

colors=(none) ctitle=black  horigin=0.5 cm    vorigin= 13 cm;

ods noptitle;

proc gmap data=PC.base map=maps.africa all  ;*gout=sasuser.hert;

choro Medfe60/discrete coutline=red cempty=red nolegend  description='1955-69' name='carte1';

  id id;

  format Medfe60 Fagefe.;

title  h=0.3 cm f=simplex '1955-69';

run;

quit;

   pattern1 v=s c=cxFFFF00;

   pattern2 v=s c=cxffb000;

   pattern3 v=s c=cxff7000;

   pattern4 v=s c=cxff1000;

   pattern5 v=s c=white;

    goptions hsize=8.6 cm vsize=9.2 cm target=jpeg devmap=winansi keymap=winansi

colors=(none) ctitle=black horigin=9.5 cm    vorigin= 13 cm;

legend1 across=1 down=4  position=(bottom inside left)

label=(j=left f=simplex position=top 'Age')  value=(j=left f=simplex  h=0.35 cm);

ods noptitle;

proc gmap data=PC.base map=maps.africa all;* gout=sasuser.hert;

choro Medfe70/discrete coutline=red cempty=red name='carte2'

               legend=legend1  description='1970-79';

  id id;

  format Medfe70 Fagefe.;

title h=0.3 cm f=simplex '1970-79';

run;

quit;

   pattern1 v=s c=cxFFFF00;

   pattern2 v=s c=cxffb000;

   pattern3 v=s c=cxff7000;

   pattern4 v=s c=cxff1000;

   pattern5 v=s c=white;

    goptions hsize=8.6 cm vsize=9.2 cm target=jpeg devmap=winansi keymap=winansi

colors=(none) ctitle=black  horigin=0.5 cm    vorigin= 1 cm;

ods noptitle;

proc gmap data=PC.base map=maps.africa all ;*gout=sasuser.hert;

choro Medfe80/discrete coutline=red cempty=red nolegend  description= '1980-89' name='carte3';

  id id;

  format Medfe80 Fagefe.;

title h=0.3 cm f=simplex '1980-89';

run;

quit;

   pattern1 v=s c=cxFFFF00;

   pattern2 v=s c=cxffb000;

   pattern3 v=s c=cxff7000;

   pattern4 v=s c=cxff1000;

   pattern5 v=s c=white;

      goptions hsize=8.6 cm vsize=9.2 cm target=png devmap=winansi keymap=winansi

colors=(none) ctitle=black horigin=9.5 cm    vorigin= 1 cm;

legend1 across=1 down=4 position=(bottom inside left)

label=(j=left f=simplex position=top 'Age')  value=(j=left f=simplex  h=0.35 cm);

ods noptitle;

proc gmap data=PC.base map=maps.africa all;* gout=sasuser.hert;

choro Medfe90/discrete coutline=red cempty=red name='carte4'

               legend=legend1  description='1990-99';

  id id;

  format Medfe90 Fagefe.;

title h=0.3 cm f=simplex '1990-99';

run;

quit;

ods pdf close;

Occasional Contributor
Posts: 6

Re: Using the Origin= Option in an Axis Statement

Thanks Andre,

Nice piece of code, thanks. I've never had a problem using decimals with horigin/vorigin or with hsize/vsize either. I hope somebody knows how to fix or work around the case with axis origins!

Les

Super Contributor
Posts: 273

Re: Using the Origin= Option in an Axis Statement

Ok

of course this is only a problem of origin option in axis statement

Suggestion

As pdf is a printer destination use only pt as it is small enaugh to entire numbers.

And it is small too for moving inside your two evident areas

And see what happens.

I have no other idea

Andre

Occasional Contributor
Posts: 6

Re: Using the Origin= Option in an Axis Statement

That was my thought as well, but it failed... (See the axis41 and axis42 effort above).

Solution
‎04-03-2014 01:50 PM
Grand Advisor
Posts: 9,748

Re: Using the Origin= Option in an Axis Statement

I would expect failure with 1pct 1pt and likely 1cell as axis text needs to display label and values. Which is at least 2 cells and almost guaranteed to be more than 1pt. The shift of the orgin within the graph display to that close to the left/bottom area isn't leaving room for text. With a graph size of 2.5x2.5 inches 1pct means 0.025 inches, which also won't allow any space for actual text.

I ran some of this code and get error messages like;

 

ERROR: The specified y-origin for the bottom horizontal axis labeled x did not leave enough space

for the text. You need to specify ORIGIN=( , 8.6 PERCENT ). The graph was not produced.

So that says exactly what the smallest value would work with the current settings.

Also, why in your examples are you changeing the Goptions for horigin and vorigin? That just complicates figuring out what the axis statments are doing.

Occasional Contributor
Posts: 6

Re: Using the Origin= Option in an Axis Statement

I've seen error messages like "You need to specify ..." when I try to set the length of the axis, but I've never seen if for the current situation. Never seen the warnings about not enough space for the text although I see them often in other situations even where the graph looks just fine. The only time I see the missing values is when I try to set the origin.

I've been concerned about collision between different specifications, so that's why I tried to stay as close as I could to my original setup including multiple graphs on the page. However, as you say we can generate the same error with a single simple graph.

Thanks for all the help. More experimenting showed that you were exactly right -- the error about missing values is generated when the printed axis label or values are cut off, by shifting the origin too far to the left or down. No error is generated when the graph area is cut off by shifting too far to the right or up, although you do get a warning about strings extending beyond the device boundary.

It would be nice to see the documentation explain this behavior.

Post a Question
Discussion Stats
  • 8 replies
  • 2804 views
  • 3 likes
  • 3 in conversation