IDL 直接图像法绘制直方图(自定义坐标范围,图名、坐标轴支持中文字符)

时间:2021-12-01 14:56:22

;显示直方图
      !P.Multi = [0, 2, 1, 0, 1]
      !P.FONT = 0
     
      DEVICE,SET_FONT = "宋体*14"
      window,XSIZE=600,YSIZE=300,TITLE='拉伸前后影像直方图对比',COLORS=2
;      p1=plot(HISTOGRAM(forImage),TITLE = '原始影像直方图',XTITLE = '灰度值',YTITLE = '频数',$
;             font_name= 'Microsoft Yahei',BACKGROUND_COLOR=[194, 217, 247]) 
;      p2=plot(HISTOGRAM(afterImage),TITLE = '拉伸后影像直方图',XTITLE = '灰度值',YTITLE = '频数',$
;             font_name= 'Microsoft Yahei',BACKGROUND_COLOR=[194, 217, 247])

      PLOT, HISTOGRAM(forImage),/XSTYLE, YSTYLE=1,YRANGE=[0,600000],$
      TITLE = '原始影像直方图', $
      XTITLE = '灰度值', $
;      YTITLE = 'Numbers of Pixels',$
      FONT=0
      XYOUTS, 10,220, '灰!C!C度!C!C值!C!C频!C!C数', /DEVICE

      PLOT, HISTOGRAM(afterImage),/XSTYLE,YSTYLE=1,YRANGE=[0,600000],$
      TITLE = '拉伸影像直方图', $
      XTITLE = '灰度值', $
;      YTITLE = 'Numbers of Pixels'
      FONT=0
      XYOUTS, 310,220, '灰!C!C度!C!C值!C!C频!C!C数', /DEVICE