X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 21 Feb 2013 02:11 PM by  anon
Problems with CONTOUR Function
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
21 Feb 2013 02:11 PM
    Hello, I am trying to use the new IDL graphics, but am struggling with a couple aspects. I have two questions: 1. How can you overplot a single contour that has a value of ZERO? If I set c_value=0, that tells CONTOUR to use N_LEVELS. I can generate the filled contour plot just fine, but I like to overplot the zero line. 2. How can you change the number of major ticknames for the COLORBAR function? I would like to compose a figure that has e.q. 21 filled contours, but a discrete color bar that has a tick interval of e.g. 4. I have tried applying many of the properties, but none work! Here is an example: ;TESTING*** ; Make Discrete Color Levels ct_number = 39 nlevels=21 fdata=findgen(256,80)/(256*80)-0.5 levels=(findgen(nlevels)-(nlevels-1)/2.)*max(fdata)/(nlevels-1)*2. ct_indices = BYTSCL(levels) LOADCT, ct_number, RGB_TABLE=ct, /SILENT step_ct = CONGRID(ct[ct_indices, *], 256, 3) c1 = CONTOUR(fdata, $ indgen(256),indgen(80), $ c_value = levels, $ RGB_TABLE = step_ct, $ RGB_INDICES = ct_indices, $ /FILL, /buffer, xstyle=1,ystyle=1, $ MARGIN = [0.15, 0.20, 0.15, 0.15], $ TITLE = 'TESTING') c2 = CONTOUR(fdata, $ indgen(256),indgen(80), $ c_value = 0, c_color=0, n_levels=1, c_label_show=0,$ xstyle=1,ystyle=1,overplot=1) cb = COLORBAR( $ TARGET = c1, $ TICKLEN = 0, $ MAJOR = 5, $ FONT_SIZE = 10, $ BORDER=1, $ POSITION = [0.2, 0.07, 0.8, 0.1]) c1.save, 'testing.png' Any help would be much appreciated! Thank you, Rob

    Deleted User



    New Member


    Posts:21
    New Member


    --
    10 Apr 2013 12:26 PM
    Hi Rob, Sorry it took so long to respond. I think the trick to getting the 0 contour level is to just use a 1-element array. Regarding the colorbar, if you have a "discrete" colorbar, then IDL wants to use 1 tick mark per contour level. The best way to override this is to just set the ticknames to null strings, except where you want a label. Here's an example: ; Make Discrete Color Levels ct_number = 39 nlevels=21 fdata=findgen(256,80)/(256*80)-0.5 levels=(findgen(nlevels)-(nlevels-1)/2.)*max(fdata)/(nlevels-1)*2. ct_indices = BYTSCL(levels) LOADCT, ct_number, RGB_TABLE=ct, /SILENT step_ct = CONGRID(ct[ct_indices, *], 256, 3) c1 = CONTOUR(fdata, /debug, $ indgen(256),indgen(80), transparency=50, $ c_value = levels, $ RGB_TABLE = step_ct, $ RGB_INDICES = ct_indices, $ /FILL, buffer=0, xstyle=1,ystyle=1, $ MARGIN = [0.15, 0.20, 0.15, 0.15], $ TITLE = 'TESTING') c2 = CONTOUR(fdata, $ indgen(256),indgen(80), $ c_value = [0], c_color=0, c_label_show=0,$ xstyle=1,ystyle=1,overplot=1) cb = COLORBAR( $ TARGET = c1, $ TICKLEN = 0, $ FONT_SIZE = 10, $ BORDER=1, $ POSITION = [0.2, 0.07, 0.8, 0.1]) tickname = STRARR(N_ELEMENTS(levels)) tickname[INDGEN(5)*4] = STRING(levels[INDGEN(5)*4],FORMAT='(F5.2)') cb.TICKNAME=tickname Hope this helps! -Chris ExelisVIS
    You are not authorized to post a reply.