Re: iplot colorbar label [message #67874] |
Wed, 09 September 2009 13:02  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Sep 9, 11:42 am, "Thibault ." <garthalg...@yahoo.fr> wrote:
> Hi,
>
> Using iplot as a scatter plot, I assign colors to the data points
> according to an array (using vert_colors) and I want to create the
> corresponding colorbar with /insert_colorbar:
>
> x=randomu(41,10)
> y=randomu(50,10)
>
> my_col=[150,255,12,160,187,245,36,58,210,170]
>
> iplot,x,y,/insert_colorbar,rgb_table=39,sym_index=4,/
> scatter,vert_colors=my_col
>
> Doing that, the plot works and the colorbar is displayed BUT the
> colorbar label goes from 0 to 1. I noticed that it goes from min to
> max values of the y variable... whereas I want the label to span what
> it really represents, namely the my_col array !!!
>
> How to make the colorbar label ranging from 0 to 255 ( = the my_col
> array min and max values) ?
Actually I agree that the colorbar ticks should not be the color
indexes, because usually the colorbar should show the "physical"
quantity mapped by the color, not the index on the colortable (though
you could make that quantity be the index, if that is what you
wanted). In an interface that allows to set point colors directly (by
vert_colors), the itool is given no information on how colors map to a
variable (which is what a colorbar indicates), and as such, it should
not be able to put a colorbar in there.
In that sense, I find the iplot interface is incomplete, as it should
have a keyword to indicate the quantity that should map to the color
(something like vert_values), which is another limitation of how IDL
handles colorbars. The limitation that particularly annoys me is only
256 levels in a colorbar, and I havebeen working on larger colorbars.
Not having that keyword and not knowing what variable maps to the
colors, it guesses that variable to be the last variable passed as
argument (in that case, y).
Anyway, it is still possible to go around the iplot interface, and
change the colorbar labels after it is made. I have a function that I
made for that, pp_colorbar_range, which could be used in your case as
something like:
pp_colorbar_range,[0,255],font_size=12.
After the iplot with the colorbar, if what you want is really for the
colorbar to show the range 0,255. But I suspect that you have some
other range that would make more sense, which is the range of the
variable used to determine vert_colors.
pp_colorbar_range is at
http://www.ppenteado.net/idl/pp_colorbar_range.html
http://www.ppenteado.net/idl/pp_colorbar_range.pro
|
|
|