Choose Language Hide Translation Bar
Highlighted
cwillden
Super User

Coerce Bars in PlotColBox to Draw from 0 Origin

Hey Community,

 

I'm trying to mimic a table box in a report like you get with TukeyHSD in Fit Y by X, but I'm running into a problem with the bar chart drawn in a PlotColBox.  Bar lengths are plotted with confidence intervals for each bar.  My problem is that I want the bars to be drawn from the origin so that you can visually see where the lower confidence limit dips below 0 (indicating a non-significant result), but the bars are being drawn from the minimum value on the scale.   I cannot find anything in the scripting index to modify this behavior.

 

Ultimately, it should closely resemble the plot in this ordered differences report:Tukey.PNG

Here's what I am getting (minimal working example shown here):GH.png

I set the range on the horizontal axis on the plot using << Set Scale and setting it equal to the min LCL and max UCL so that he plot will be wide enough to show all of the LCL and UCL values, but this causes the bars to be drawn starting at the same minimum value.

Here's a script for the minimal working example:

diffs = {14.5833333333333, 13.25, 13.1666666666667, 12.4166666666667, 11.8333333333333,
11.75, 11, 10.4166666666667, 9.58333333333333, 2.83333333333333, 2.16666666666667,
1.41666666666667, 1.41666666666667, 1.33333333333333, 0.833333333333334};

lcls = {7.61907259396521, 8.36035077512539, 6.22561115938687, 7.05705972526408,
6.99299436545608, 4.7114849776621, 5.68093889133607, 5.37459986573576,
4.09680778320344, -0.348570126295593, -5.63501808685501, -1.64446371477212,
-1.1943038377427, -6.25265936207625, -5.48781669649702};

ucls = {21.5475940727015, 18.1396492248746, 20.1077221739465, 17.7762736080693,
16.6736723012106, 18.7885150223379, 16.3190611086639, 15.4587334675976,
15.0698588834632, 6.01523679296226, 9.96835142018835, 4.47779704810545,
4.02763717107603, 8.91932602874292, 7.15448336316369};

New Window("Results",
	tb = Table Box(
		Number Col Box("Difference", diffs),
		Number Col Box("LCL", lcls),
		Number Col Box("UCL", ucls),
		Number Col Box("p-Value", p_vals[sort], Set Format(7, 97), Set Conditional Format("pValue")),
		Plot Col Box("", diffs, Upper(matrix(ucls)), Lower(matrix(lcls)), Set Scale(min(lcl), max(ucl)))
	)
);

Thanks in advance for the help!

-- Cameron Willden
2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
gzmorgan0
Super User

Re: Coerce Bars in PlotColBox to Draw from 0 Origin

Hi Cameron, This seems to work:

  • Fix the size with dummy values
  • Remove the dummies.
Names Default to Here(1);

diffs = {14.5833333333333, 13.25, 13.1666666666667, 12.4166666666667, 11.8333333333333,
11.75, 11, 10.4166666666667, 9.58333333333333, 2.83333333333333, 2.16666666666667,
1.41666666666667, 1.41666666666667, 1.33333333333333, 0.833333333333334};

lcls = {7.61907259396521, 8.36035077512539, 6.22561115938687, 7.05705972526408,
6.99299436545608, 4.7114849776621, 5.68093889133607, 5.37459986573576,
4.09680778320344, -0.348570126295593, -5.63501808685501, -1.64446371477212,
-1.1943038377427, -6.25265936207625, -5.48781669649702};

ucls = {21.5475940727015, 18.1396492248746, 20.1077221739465, 17.7762736080693,
16.6736723012106, 18.7885150223379, 16.3190611086639, 15.4587334675976,
15.0698588834632, 6.01523679296226, 9.96835142018835, 4.47779704810545,
4.02763717107603, 8.91932602874292, 7.15448336316369};
p_vals = {.00001, .00002, .00003, .00004, .00005, .0003, .00006, .00007, .0001, .0557,
	 .9247, .6006, .4466, .9888, .9972
};

ndiffs = Insert(diffs,   eval List({min(lcls), max(ucls)} ) );
New Window("Results",
  OutlineBox("Custom Table",
	tb = Table Box(
		Number Col Box("Difference", diffs),
		Number Col Box("LCL", lcls),
		Number Col Box("UCL", ucls),
		Number Col Box("p-Value", p_vals, Set Format(7, 97), Set Conditional Format("pValue")),
		pcb = Plot Col Box("", ndiffs)
	)
 )
);
nr = nitems(ucls);

pcb << delete row(nr+2);
pcb << delete row(nr+1);
pcb <<lower(matrix(lcls));
pcb << upper(matrix(ucls));

image.png

View solution in original post

Highlighted
gzmorgan0
Super User

Re: Coerce Bars in PlotColBox to Draw from 0 Origin

@cwillden This also works:

scl = evallist({min(lcls), max(ucls)});
New Window("Results",
  OutlineBox("Custom Table",
	tb = Table Box(
		Number Col Box("Difference", diffs),
		Number Col Box("LCL", lcls),
		Number Col Box("UCL", ucls),
		Number Col Box("p-Value", p_vals, Set Format(7, 97), Set Conditional Format("pValue")),
		pcb = Plot Col Box("", scl  )
	)
 )
);
pcb << add element(diffs);
pcb << delete row(2);
pcb << delete row(1);
pcb << lower(matrix(lcls));
pcb << upper(matrix(ucls));

View solution in original post

3 REPLIES 3
Highlighted
gzmorgan0
Super User

Re: Coerce Bars in PlotColBox to Draw from 0 Origin

Hi Cameron, This seems to work:

  • Fix the size with dummy values
  • Remove the dummies.
Names Default to Here(1);

diffs = {14.5833333333333, 13.25, 13.1666666666667, 12.4166666666667, 11.8333333333333,
11.75, 11, 10.4166666666667, 9.58333333333333, 2.83333333333333, 2.16666666666667,
1.41666666666667, 1.41666666666667, 1.33333333333333, 0.833333333333334};

lcls = {7.61907259396521, 8.36035077512539, 6.22561115938687, 7.05705972526408,
6.99299436545608, 4.7114849776621, 5.68093889133607, 5.37459986573576,
4.09680778320344, -0.348570126295593, -5.63501808685501, -1.64446371477212,
-1.1943038377427, -6.25265936207625, -5.48781669649702};

ucls = {21.5475940727015, 18.1396492248746, 20.1077221739465, 17.7762736080693,
16.6736723012106, 18.7885150223379, 16.3190611086639, 15.4587334675976,
15.0698588834632, 6.01523679296226, 9.96835142018835, 4.47779704810545,
4.02763717107603, 8.91932602874292, 7.15448336316369};
p_vals = {.00001, .00002, .00003, .00004, .00005, .0003, .00006, .00007, .0001, .0557,
	 .9247, .6006, .4466, .9888, .9972
};

ndiffs = Insert(diffs,   eval List({min(lcls), max(ucls)} ) );
New Window("Results",
  OutlineBox("Custom Table",
	tb = Table Box(
		Number Col Box("Difference", diffs),
		Number Col Box("LCL", lcls),
		Number Col Box("UCL", ucls),
		Number Col Box("p-Value", p_vals, Set Format(7, 97), Set Conditional Format("pValue")),
		pcb = Plot Col Box("", ndiffs)
	)
 )
);
nr = nitems(ucls);

pcb << delete row(nr+2);
pcb << delete row(nr+1);
pcb <<lower(matrix(lcls));
pcb << upper(matrix(ucls));

image.png

View solution in original post

Highlighted
cwillden
Super User

Re: Coerce Bars in PlotColBox to Draw from 0 Origin

Great idea!  Let me work this into my actual script, but I expect this will work perfectly.  Thanks!

-- Cameron Willden
Highlighted
gzmorgan0
Super User

Re: Coerce Bars in PlotColBox to Draw from 0 Origin

@cwillden This also works:

scl = evallist({min(lcls), max(ucls)});
New Window("Results",
  OutlineBox("Custom Table",
	tb = Table Box(
		Number Col Box("Difference", diffs),
		Number Col Box("LCL", lcls),
		Number Col Box("UCL", ucls),
		Number Col Box("p-Value", p_vals, Set Format(7, 97), Set Conditional Format("pValue")),
		pcb = Plot Col Box("", scl  )
	)
 )
);
pcb << add element(diffs);
pcb << delete row(2);
pcb << delete row(1);
pcb << lower(matrix(lcls));
pcb << upper(matrix(ucls));

View solution in original post

Article Labels

    There are no labels assigned to this post.