我想在IDL中将二维矩阵绘制为伪彩色图,就像matlab中的函数
pcolor
一样。我知道函数image
可以做到这一点,但我希望它可以生成像plot
、scatterplot
等IDL Graphics,以便使用Graphics的方法和关键字。我当前的程序(见下文)循环 polygon
来绘制每个矩形像素,这需要太长时间。有没有简单的方法可以做到这一点?
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
您的意思是当您显示小图像时希望像素之间有黑线来指示每个像素吗?无需为每个像素绘制单独的多边形,只需为每行绘制一个水平多边形,为每列绘制一个垂直多边形即可。
如果不需要分割线,只需调用
image
即可完成:
IDL> im = image(my_image, rgb_table=my_rgb_table)