I have the following graph showing two variables x and y for each group on y-axix. I'd like to separate blue and red line for each group for a clearer presentation; something like having two very close line (one for x and one for y) for each group on the y-axis. Any suggestion?
If you are using SAS 9.4, you can use JITTER option in your SCATTER statement to separate the lines.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p1lcbd3lhs3t3bn1jk6d8sjt2yqx.htm
Related
I want to create a two-panel graph using proc sgpanel in SAS 9.4. The y-axis should be the same for the two panels, but I want both x-axis to have different values . Can that be done using SGPANEL?
Best regards,
Shaifali
Yes, use the UNISCALE option on your PANELBY statement to specify which axis you want fixed, the col, row or both. The default is both, which is not what you want, so specify that only the cols are fixed.
panelby yourSpecifications / uniscale = cols;
I actually work on power BI with some simple date(just integer). And I try to make a line chart in blue. But when the values go to 0 I want the grey line chart... I try to make 2 dinstinct line chart but it doesn't work and I try to change my x-axis from continuous to categorical but it show me something weird...
here's an quicklook on my date and chart:
I have a RRD database with data:
"DS:pkts_transmitted:GAUGE:120:0:U",
"DS:pkts_received:GAUGE:120:0:U",
"DS:pkts_lost:GAUGE:120:0:U",
"DS:rtt_min:GAUGE:120:0:U",
"DS:rtt_avg:GAUGE:120:0:U",
"DS:rtt_max:GAUGE:120:0:U",
And I want that the Avg line change colour if I lose any package.
For example, if I lose 5 packets make the line blue, if I lose 10 make it red.
I see people doing it but I read the documentation and I can't find how to do this.
The way to do this is to actually have multiple lines defined (one of each colour) and hide the ones you don't want to see at any time, using calculations.
For example, say we have an RRD with two DSs:
DS:x:GAUGE:60:0:U
DS:y:GAUGE:60:0:1
Now, we want to show the line for x in red if y is 0, and blue if it is 1. To do this, we create two calculated values, x1 and x2.
CDEF:x1=y,0,EQ,x,UNKN,IF
CDEF:x2=y,1,EQ,x,UNKN,IF
Thus, x1 is active if y=0 and x2 if y=1. Yes, this could be simplified, but I'm showing it like this for the example.
Now, we can make lines using these:
LINE:x1#ff0000:MyLine
LINE:x2#0000ff
Note that the second line doesn't need a legend. Now, the line will appear to change colour depending on the value of the y metric, since at any time the other line will be UNKN and therefore not displayed.
You can extend this, of course, to have multiple colours and more complex thresholds.
For some reason, I just can't get this to work. What I end up getting is two grids with axes plotted on top of each other and then the second plot plotted under this. My code works fine for a seaborn distplot:
plt.subplot(121)
h = sns.distplot(dfmain["Runs"])
plt.subplot(122)
j = sns.distplot(dfHighScores["Runs"])
But if I try and plot two factor plots side by side (they are independent so I don't want the axes to be shared), then this just doesn't work as described above:
plt.subplot(121)
h = sns.factorplot("Runs",data=dfmain)
plt.subplot(122)
j = sns.factorplot("Runs",data=dfHighScores)
I get this behavior whether I use an iPython notebook or spyder as my IDE. Any help would be greatly appreciated.
According to the documentation of factorplot it should be able do draw two plots side by side by itself. If you combine both your data frames into one (and add a column to tell between them) then something like this should work:
sns.factorplot("Runs", col="mainOrHighScores", data=dfCombined)
Otherwise I think factorplot doesn't operate on axes (unlike distplot).
In any case only functions that have an "ax" parameter for axes can draw on axes.
There was a similar question to this before (how to prevent midpoints from extending), but does not answer my question.
I'm creating a histogram as follows and outputting it to a PNG file:
ods graphics on / imagename = "histoOne" imagefmt = png reset=index border=off width=4in;
ods select where=(_name_ ? 'Histogr');
proc univariate data=myData noprint; *(WHERE=(sumStake < 250));
Title1;
var sumStake;
histogram sumStake / name='histogr' vminor=4 grid lgrid=34 endpoints=0 to 250 by 20 cfill=red;
*Omit the inset, because the stats refer to the reduced dataset;
INSET n (comma11.0) mean (5.2) median (5.2) std='Std Dev'(5.2) max='Max' (5.2) / pos = ne
header = 'Summary Statistics' cfill = ywh;
run;
ods graphics off;
I want to display both the histogram and the summary statistics inset. However, the data is so skewed, that it makes no sense to show the maximum value for sumStake on the X-Axis. I want to cap the X-Axis at 250.
SAS keeps extending the ENDPOINTS value. How can I suppress this?
I don't want to use the (WHERE=(sumStake < 250)); filter as the count, mean, median and max in the inset will be based on the reduced sample, rather than the entire sample and will make no sense.
You may need to change your data in some fashion, or do the graph in a different way. Histograms in SAS don't allow much mucking about with the data in this fashion; you have to do it ahead of time. Histograms are meant largely for showing how your data falls out, so it's a bit counterintuitive to 'hide' some of the data fallout - I understand why you want to, but it is not exactly the primary purpose of histograms, hence why the functionality isn't there in SAS.
I don't think in any event that PROC UNIVARIATE gives you any ability to control this, so you may lose the inset. You can control the axis length explicitly in PROC SGPLOT histograms (with an AXIS statement in PROC SGPLOT), but they don't have the same kind of inset - you could make something probably, but not as simply. It also will still make the oversized bins, and won't reallocate those over-binned records.
Another option, particularly if you're making the inset separately anyway, would be to do the SGPLOT histogram (or bar chart) with data you've 'fixed' (right censored) and calculate the inset data separately (on the uncensored data).