turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- Overlay with yaxis and y2axis using same zero

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-24-2014 01:26 PM

I'm building an overlay layout that has needle plots for trades and bandplots for cumulative positions. The positions can grow to overshadow the trades, making the needles tiny, so I've placed trades on the yaxis and the position on the y2axis. I'd like the zero value of the y axes to be the same, i.e. that the axes are scaled differently, but "pinned" to a common ground. Is this possible?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to jdmarino

02-24-2014 01:38 PM

This should be doable by setting MIN =0 on both Y and Y2 axes.. You could also set OFFSETMIN=0 for both Y and Y2 axes to ensure the needles touch the X axis.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

02-24-2014 01:41 PM

Ah, but zero is in the middle: trades and positions can be positive or negative.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to jdmarino

02-24-2014 02:03 PM

Aah. Interesting. Then I suggest set the MIN and MAX for both Y and Y2 in the same proportion. So, if for band (on Y) the min= -100 and max= +200, then make the min and max for the needle (on Y2) in the same proportion. So, if the needle min= -20 and max=+20, make Y2 min= -20 and max=+40. I believe this should set the zero at the same place for both axes. Place a reference line for Y=0 and see how it lines up with Y2.

data synch;

do x=1 to 10 by 1;

y1=10*rannor(2);

y2=rannor(2);

output;

end;

run;

proc sgplot data=synch cycleattrs;

series x=x y=y1;

needle x=x y=y2 / y2axis;

refline 0;

yaxis min=-10 max=20;

y2axis min=-2 max=4 valueattrs=graphdata2 labelattrs=graphdata2;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

02-24-2014 02:46 PM

Thanks. I guess I did not overlook the built-in option for this to does it automagically.

I don't want to hard code these values, and detecting them and scaling sounds like a fair bit of effort. I'm using proc template and I'd have to pass some dynamic or macro vars, which I find troublesome (i.e. I have trouble getting them to work).

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to jdmarino

02-24-2014 03:28 PM

No, automatic solution at this time. Yes, you can use some logic to compute the min and max values in macro variables, and set on the axis. Alternately, do you have to use overlaid plots? Could you place each plot in its own graph, with a common x axis. Or, use the Waterfall chart, where each observation is a transaction and the cumulative result is automatically computed. Waterfall is available in SG, but to create a two cell graph with common X axis, you need GTL.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

02-24-2014 04:25 PM

Thanks again for all the help. I don't have to use overlaid charts, and I think that's the best option. Waterfall may work, so long as I can give it a starting base value. (The graph actually has needles for two kinds of trading [stocks and swaps], a band for each, and a seriesplot fo the total cumulative position. I'm not inclined to ditch it all at this point.) It's interesting that so many chart types can be transformed to server other purposes.