X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 07 Apr 2011 02:19 PM by  anon
IDL 8.0 Contour function
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
07 Apr 2011 02:19 PM
    I am playing with the new contour function. I would like to generate a series of contour plots with fixed scales. However, I could not find the argument that I can use to specify the exact levels I want. I have tried n_levels, min_value and max_value, c_value...None of them work. Help!!

    Deleted User



    New Member


    Posts:
    New Member


    --
    22 Apr 2011 09:58 AM
    Hi there, What about this example code?: pro contour_fixed_lines_ex ; Create a simple, random dataset for contouring: data = RANDOMU(seed, 7, 7) lvls =[0,0.05,0.1,0.15,0.2,0.3,0.4,0.5,0.6] CONTOUR, data, LEVELS=lvls, C_LABELS=[1,0,1,0,1,0,1,0], C_CHARSIZE = 1.25 ctr=contour(data, C_VALUE=lvls, FONT_SIZE=7) ctr.C_LABEL_SHOW=[1,0,1,0,1,0,1,0] end Remember, the contour function has new and sometimes different ways of doing the same than in the contour routine. You need to try to find the equivalent way. As you can see sometimes you can modify the contour properties by applying the method to the contour object (here called ctr). Cheers, Fernando

    Deleted User



    New Member


    Posts:
    New Member


    --
    07 Sep 2011 11:04 AM
    I tried your contour_fixed_lines_ex.pro. It works. In an application, I need to compare a few plots with the same scale. That is, I need to use the same grey levels in those plots. To test the resulting plot change with the C_VALUE, I modified your example to this: ---------------------------------------------------------- pro contour_fixed_lines_ex ; ; To show the problem of the C_VALUE in the contour(). ; Kam Wan, Sept 7, 2011. ; The next four lines are to show where the data array is from. ; i.e. The rdata1 file should be created by running this code with ; the four lines uncommented. ;;;;;;;;; Create a simple, random dataset for contouring: ;data = RANDOMU(seed, 51, 51) ;openw, 10, 'rdata1' ;writeu, 10, data ;close,10 data = fltarr (51, 51) data0 = coa('rdata1', 1, 51, 51) data = data0(0) lvls =[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0] ; ****** This is the test. ; In the first run, this line is commented out. ; In the second run, it is NOT commented. ;lvls = lvls * 2. ; ************ ; This is to sure that different lvls is used. print, lvls[10] ;CONTOUR, data, LEVELS=lvls, C_LABELS=[1,0,1,0,1,0,1,0], C_CHARSIZE = 1.25 ;ctr=contour(data, C_VALUE=lvls, FONT_SIZE=7, rgb_table=4, n_levels=30, /fill) ctr=contour(data, C_VALUE=lvls, FONT_SIZE=7, rgb_table=4, n_levels=30 ) c1 = colorbar(TARGET=ctr,position=[0.05,0.10,0.5,0.13] ) end ------------------------------------------------------------------------------------ With these modifications, I can use the same data array with different levels. The two contour plots I got (by commenting, or un-commenting, the 'lvls=lvls*2' line) are identical. So, it seems that the contour() doesn't really care about the array given to C_VALUE. The colorbar is consistent with the contour plot, but also doesn't care about the levels array. These are my problems. There may be other option to tell the contour() to use different level-array!?

    Deleted User



    New Member


    Posts:
    New Member


    --
    12 Sep 2011 05:01 PM
    It seems to me you are complaining about the color bars that are associated with these contour plots. And you are right, the Colorbar() function doesn't care about the levels at all. It only cares about the data in the contour plot. To my mind it makes the Colorbar function almost useless. The only way to obtain the same color bar with different data sets is to create a fake contour plot with the data range you want the color bar to display and attach the color bar to that fake contour plot. After the color bar is displayed, you can delete the fake contour plot. See this article, near the end, for an example: http://www.idlcoyote.com/ng_tips/elephant.php
    You are not authorized to post a reply.