LGSInnovations / sigplot

SigPlot provides fast interactive web-plotting for software defined radio.
https://sigplot.lgsinnovations.com
Apache License 2.0
36 stars 26 forks source link

Would like to be able to turn off colorbar when displaying only 1d layers #26

Closed sterre closed 5 years ago

sterre commented 6 years ago

A SigPlot instance always displays a colorbar, even if all layers are 1d. Since the colorbar is not related to the display in this case, it seems extraneous.

I believe the relevant code is in display_specs. There's a conditional which checks whether to display a large colorbar based on Gx.lg_colorbar AND the class of layer zero. The else clause unconditionally draws a colorbar:

if (Gx.lg_colorbar && (Gx.lyr[0].hcb["class"] === 2)) {
    // settings for large colorbar
} else { 
    // settings for small colorbar
}
mx.colorbar(...);

If we separate the class check from the large/small check, we could skip the drawing altogether:

if (Gx.lyr[0].hcb["class"] === 2) {
    if (Gx.lg_colorbar) {
        // settings for large colorbar 
    } else {
        // settings for small colorbar
    }
    mx.colorbar(...);
}

An alternative would be to have another option explicitly controlling whether the colorbar is drawn, but that seems less humane to me for the straightforward case.

maihde commented 6 years ago

@sterre this sounds good to me with one caveat. SigPlot allows you to combine 2D and 1D layers within the same plot (or multiple 2-D layers with different capacities) so it might be more appropriate to check all of the layers within Gx.lyr to see if any of them are 2D. If so, then a colorbar will be displayed.

Sound good?

sterre commented 6 years ago

Yes, that makes sense to me.

maihde commented 5 years ago

@sterre sorry this took so long for me to get around to. I just published a pull request.