How to create pseudo-color figures with IDL Graphics

48 Views Asked by At

I want to plot a 2-D matrix as a pseudo-color figure in IDL, just like the function pcolor in matlab. I know the function image can do that, but I hope it can generate IDL Graphics like the plot, scatterplot, etc, in order to use the methods and keywords of Graphics. My current procedure(see below) loops the polygon to plot every rectangular pixel, which takes too long. Is there a brief way to make that?

  gr = plot([x_vertex[0]],[y_vertex[0]],_EXTRA=ex)
  for i = 0,n_elements(x)-2 do begin
    for j = 0,n_elements(y)-2 do begin
      if ~finite(z[i,j]) then continue

      pl = polygon([x_vertex[i],x_vertex[i+1],x_vertex[i+1],x_vertex[i]],$
        [y_vertex[j],y_vertex[j],y_vertex[j+1],y_vertex[j+1]],$
        fill_color=color_list[i,j],/data,rgb_table=rgb_table,linestyle=6)
      ; color_list is calculated from z
    endfor
  endfor
1

There are 1 best solutions below

1
On

Do you mean you want black lines between the pixels when you are displaying a small image to indicate each pixel? No need to draw a separate polygon for each pixel, just draw one horizontal one for each row and one vertical one for each column.

If you don't need the dividing lines, just a single call to image should do it:

IDL> im = image(my_image, rgb_table=my_rgb_table)