Simulating imagesc in CDAT


How do I simulate the MATLAB imagesc function and make plots with color bars that are scaled over the same range?


The imagesc function in MATLAB creates plots that have color bars scaled to a user-specified range. This allows you to simply create a whole series of plots that can be easily intercompared.

The following function imitates imagesc:

import vcs
def imagesc(x, mini, maxi):
    t = vcs.init()
    a = t.getboxfill('quick')
    a.level_1 = mini
    a.level_2 = maxi
    t.plot(x, a)

x is the input array and mini and maxi define the range in values to plot. The function establishes a VCS canvas, imports the "quick" boxfill graphics method, sets the level range to mini and maxi, and plots x using this customized graphics method.

Thanks to Hae-Kyung Im (Department of Statistics, University of Chicago) for the solution!

Return to the Tips and Examples index page.

Valid HTML 4.01! Valid CSS! Updated: June 22, 2004 by Johnny Lin <email address>.