plotBox - "Minimum Ink" style

In the pbox.e example for the old PQG graphics, one of the available styles is Edward Tufte's "Minimum Ink" style, which just reduces the width of the central box to zero.

 

Is there a way to recreate this style with plotBox() ?

3 Answers



0



I believe there are two variants of box plots proposed by Tufte. The current implementation of plotBox does not allow either of these styles, but you could make either of them with plotXY and plotScatter. Here is some code to produce one of the styles.

rndseed 345345;

x = rndn(100, 4);
plotTufteBox(x);

proc (0) = plotTufteBox(x);
    //Line settings
    struct plotControl myPlot;
    myPlot = plotGetDefaults("xy");
    plotSetLineColor(&myPlot, "black");
    plotSetLegend(&myPlot, "off");
    
    //Get data to create box
    y = zeros(5, cols(x)) .* error(0);
    y[1,.] = minc(x)';
    y[2 4,.] = quantile(x, 0.25|0.75);
    y[5,.] = maxc(x)';
    
    x1 = reshape(seqa(1, 1, cols(y)), rows(y), cols(y));
    plotXY(myPlot, x1, y);
    
    //Set 
    myPlot = plotGetDefaults("scatter");
    plotSetLineColor(&myPlot, "black");
    plotAddScatter(seqa(1, 1, cols(q)), median(x));
endp;

aptech

1,773


0



Thanks for your help.....but the code doesn't compile.

Did you forget to declare y and x1 as local?

I'm also not sure what q is supposed to be in the plotAddScatter line. Should that be a y?



0



Sorry...that is an example of why it can be good to have a "new" at the top of a program. You are, of course, correct about the local declarations. q was the variable that originally held the return from quantile. This version should work!

new;
rndseed 345345;

x = rndn(100, 4);
plotTufteBox(x);

proc (0) = plotTufteBox(x);
    local y, x1;
    struct plotControl myPlot;
    myPlot = plotGetDefaults("xy");
    plotSetLineColor(&myPlot, "black");
    plotSetLegend(&myPlot, "off");
    
    y = zeros(5, cols(x)) .* error(0);
    y[1,.] = minc(x)';
    y[2 4,.] = quantile(x, 0.25|0.75);
    y[5,.] = maxc(x)';
    
    x1 = reshape(seqa(1, 1, cols(y)), rows(y), cols(y));
    plotXY(myPlot, x1, y);
    
    myPlot = plotGetDefaults("scatter");
    plotSetLineColor(&myPlot, "black");
    plotAddScatter(seqa(1, 1, cols(y)), median(x));
endp;

aptech

1,773

Your Answer

3 Answers

0

I believe there are two variants of box plots proposed by Tufte. The current implementation of plotBox does not allow either of these styles, but you could make either of them with plotXY and plotScatter. Here is some code to produce one of the styles.

rndseed 345345;

x = rndn(100, 4);
plotTufteBox(x);

proc (0) = plotTufteBox(x);
    //Line settings
    struct plotControl myPlot;
    myPlot = plotGetDefaults("xy");
    plotSetLineColor(&myPlot, "black");
    plotSetLegend(&myPlot, "off");
    
    //Get data to create box
    y = zeros(5, cols(x)) .* error(0);
    y[1,.] = minc(x)';
    y[2 4,.] = quantile(x, 0.25|0.75);
    y[5,.] = maxc(x)';
    
    x1 = reshape(seqa(1, 1, cols(y)), rows(y), cols(y));
    plotXY(myPlot, x1, y);
    
    //Set 
    myPlot = plotGetDefaults("scatter");
    plotSetLineColor(&myPlot, "black");
    plotAddScatter(seqa(1, 1, cols(q)), median(x));
endp;
0

Thanks for your help.....but the code doesn't compile.

Did you forget to declare y and x1 as local?

I'm also not sure what q is supposed to be in the plotAddScatter line. Should that be a y?

0

Sorry...that is an example of why it can be good to have a "new" at the top of a program. You are, of course, correct about the local declarations. q was the variable that originally held the return from quantile. This version should work!

new;
rndseed 345345;

x = rndn(100, 4);
plotTufteBox(x);

proc (0) = plotTufteBox(x);
    local y, x1;
    struct plotControl myPlot;
    myPlot = plotGetDefaults("xy");
    plotSetLineColor(&myPlot, "black");
    plotSetLegend(&myPlot, "off");
    
    y = zeros(5, cols(x)) .* error(0);
    y[1,.] = minc(x)';
    y[2 4,.] = quantile(x, 0.25|0.75);
    y[5,.] = maxc(x)';
    
    x1 = reshape(seqa(1, 1, cols(y)), rows(y), cols(y));
    plotXY(myPlot, x1, y);
    
    myPlot = plotGetDefaults("scatter");
    plotSetLineColor(&myPlot, "black");
    plotAddScatter(seqa(1, 1, cols(y)), median(x));
endp;

You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.