fit image to logarithmic color bar

This is a discussion on fit image to logarithmic color bar within the Idl-pvwave forums in Programming Languages category; Dear all, I am trying to fit my data vector to a logarithmic colorbar. For the latter, I use the code suggested by David on the following link: http://www.dfanning.com/graphics_tips/logcb.html . Now, I have for example a vector X = [4.0, 0.04, 65.88, 3.62, 2.75, 7.04, 1.12,1.65] whereby my color bar ranges logarithmically from 0.001 to 100. So the colors for each of this vector point element fit my logarithmic color bar. I guess I should do something with the scale_vector function, or bytscl, but I can't seem to get it right?? I need to create a vector which contains a ...

Go Back   Application Development Forum > Programming Languages > Idl-pvwave

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-08-2008, 06:21 AM
maffie
Guest
 
Default fit image to logarithmic color bar

Dear all,

I am trying to fit my data vector to a logarithmic colorbar. For the
latter, I use the code suggested by David on the following link:
http://www.dfanning.com/graphics_tips/logcb.html.

Now, I have for example a vector X = [4.0, 0.04, 65.88, 3.62, 2.75,
7.04, 1.12,1.65]
whereby my color bar ranges logarithmically from 0.001 to 100. So the
colors for each of this vector point element fit my logarithmic color
bar. I guess I should do something with the scale_vector function, or
bytscl, but I can't seem to get it right??

I need to create a vector which contains a number (corresponding to an
element of vector X) that I can use to extract the correct number
referring to a color from the color bar. For each element, a box is
filled with a specific color (here for I am using POLYFILL, so my
image is not a continuum, but a chain of boxes, each with it's own
color. Now, I need to get the color right following my logarithmic
scale bar....

I hope this is clear and somebody can help me out?
Cheers,

Matthias
Reply With Quote
  #2  
Old 09-08-2008, 09:08 AM
David Fanning
Guest
 
Default Re: fit image to logarithmic color bar

maffie writes:

> I am trying to fit my data vector to a logarithmic colorbar. For the
> latter, I use the code suggested by David on the following link:
> http://www.dfanning.com/graphics_tips/logcb.html.
>
> Now, I have for example a vector X = [4.0, 0.04, 65.88, 3.62, 2.75,
> 7.04, 1.12,1.65]
> whereby my color bar ranges logarithmically from 0.001 to 100. So the
> colors for each of this vector point element fit my logarithmic color
> bar. I guess I should do something with the scale_vector function, or
> bytscl, but I can't seem to get it right??
>
> I need to create a vector which contains a number (corresponding to an
> element of vector X) that I can use to extract the correct number
> referring to a color from the color bar. For each element, a box is
> filled with a specific color (here for I am using POLYFILL, so my
> image is not a continuum, but a chain of boxes, each with it's own
> color. Now, I need to get the color right following my logarithmic
> scale bar....
>
> I hope this is clear and somebody can help me out?


I think you want this:

IDL> x = [4.0, 0.04, 65.88, 3.62, 2.75, 7.04, 1.12, 1.65]
IDL> Print, BytScl(x, MIN=0.001, MAX=100)
10 0 168 9 7 18 2 4

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Reply With Quote
  #3  
Old 09-08-2008, 09:51 AM
maffie
Guest
 
Default Re: fit image to logarithmic color bar

Yes!! That's it! I worked my way around with a more complex For loop
structure, but this is just perfect! That I couldn't think of that
myself!
Thank you David!

Cheers!

Oh, maybe one more question (although a bit off topic here):
I have tried to used the "Axis" command, to plot my own defined X and
Y axis. Yesterday, the axis were appearing on the plot, today, this
command doesn't result in any axis appearing in my .eps figure? Any
idea what could be the cause of this?

Here is the short axis script:

myticklen=-0.01
myticks1=['C','A','N','NE','E','SE','S','SW','W','NW']
mytickvals1=[X1+9.8, X1+(9.8*2), X1+(9.8*3), X1+(9.8*4), X1+(9.8*5),
X1+(9.8*6), X1+(9.8*7), X1+(9.8*8), X1+(9.8*9), X1+(9.8*10)]

AXIS, XAXIS=0, TICKLEN=myticklen,XTITLE='Title',$
XTICKS=9, XTICKNAME=myticks1, XTICKV=mytickvals1,color=255,
CHARTHICK=3, CHARSIZE=1.3, YTICKV = findgen(N_ELEMENTS(Astd))+0.6

Reply With Quote
  #4  
Old 09-08-2008, 10:03 AM
David Fanning
Guest
 
Default Re: fit image to logarithmic color bar

maffie writes:

> Oh, maybe one more question (although a bit off topic here):
> I have tried to used the "Axis" command, to plot my own defined X and
> Y axis. Yesterday, the axis were appearing on the plot, today, this
> command doesn't result in any axis appearing in my .eps figure? Any
> idea what could be the cause of this?


In general, you need to have set up a data coordinate system
before you can use the AXIS command. I expect it is being
drawn, but it is so tiny you can't see it. :-)

I would try using a PLOT command with the /NODATA keyword
set to draw your axes. The PLOT command will establish the
data coordinate system for you.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Reply With Quote
  #5  
Old 09-08-2008, 10:34 AM
maffie
Guest
 
Default Re: fit image to logarithmic color bar

Hum, for some reason, things doesn't seem to work.

I have added the Plot keyword as follows:

PLOT, X, /nodata,/normal,POSITION=[0.14,0.57,1,0.58]

But still I can't see any axis when putting the following after the
keyword:

myticklen=-0.01
myticks=['C','A','N','NE','E','SE','S','SW','W','NW']
myticks1=['P0','Rain','SWD','Tmax','Tmin','RH','F010','D010' ,'CC']
mytickvals=[X1+9.8, X1+(9.8*2), X1+(9.8*3), X1+(9.8*4), X1+(9.8*5),
X1+(9.8*6), X1+(9.8*7), X1+(9.8*8), X1+(9.8*9), X1+(9.8*10)]
mytickvals1=[0.1,0.3,0.6,0.8,0.9]
AXIS, XAXIS=0,TICKLEN=myticklen,XTITLE='Weather type',$
XTICKS=9, XTICKNAME=myticks, XTICKV=mytickvals,color=black,
CHARTHICK=3, CHARSIZE=1.3
AXIS, YAXIS=0, TICKLEN=myticklen,YTICKS=8, YTICKNAME=myticks1,
YTICKV=mytickvals1,color=black,CHARTHICK=3, CHARSIZE=1.3

Any more ideas??
Reply With Quote
  #6  
Old 09-08-2008, 11:42 AM
Bennett
Guest
 
Default Re: fit image to logarithmic color bar

On Sep 8, 10:34*am, maffie <matthias.demuz...@geo.kuleuven.be> wrote:
> Hum, for some reason, things doesn't seem to work.
>
> I have added the Plot keyword as follows:
>
> PLOT, X, /nodata,/normal,POSITION=[0.14,0.57,1,0.58]
>
> But still I can't see any axis when putting the following after the
> keyword:
>
> myticklen=-0.01
> myticks=['C','A','N','NE','E','SE','S','SW','W','NW']
> myticks1=['P0','Rain','SWD','Tmax','Tmin','RH','F010','D010' ,'CC']
> mytickvals=[X1+9.8, X1+(9.8*2), X1+(9.8*3), X1+(9.8*4), X1+(9.8*5),
> X1+(9.8*6), X1+(9.8*7), X1+(9.8*8), X1+(9.8*9), X1+(9.8*10)]
> mytickvals1=[0.1,0.3,0.6,0.8,0.9]
> AXIS, XAXIS=0,TICKLEN=myticklen,XTITLE='Weather type',$
> * * * * XTICKS=9, XTICKNAME=myticks, XTICKV=mytickvals,color=black,
> CHARTHICK=3, CHARSIZE=1.3
> AXIS, YAXIS=0, TICKLEN=myticklen,YTICKS=8, YTICKNAME=myticks1,
> YTICKV=mytickvals1,color=black,CHARTHICK=3, CHARSIZE=1.3
>
> Any more ideas??


I'm guessing your background is white otherwise all those color=black
will just make the axis disappear into the default black background?
Reply With Quote
  #7  
Old 09-08-2008, 11:44 AM
David Fanning
Guest
 
Default Re: fit image to logarithmic color bar

maffie writes:

> Hum, for some reason, things doesn't seem to work.
>
> I have added the Plot keyword as follows:
>
> PLOT, X, /nodata,/normal,POSITION=[0.14,0.57,1,0.58]
>
> But still I can't see any axis when putting the following after the
> keyword:
>
> myticklen=-0.01
> myticks=['C','A','N','NE','E','SE','S','SW','W','NW']
> myticks1=['P0','Rain','SWD','Tmax','Tmin','RH','F010','D010' ,'CC']
> mytickvals=[X1+9.8, X1+(9.8*2), X1+(9.8*3), X1+(9.8*4), X1+(9.8*5),
> X1+(9.8*6), X1+(9.8*7), X1+(9.8*8), X1+(9.8*9), X1+(9.8*10)]
> mytickvals1=[0.1,0.3,0.6,0.8,0.9]
> AXIS, XAXIS=0,TICKLEN=myticklen,XTITLE='Weather type',$
> XTICKS=9, XTICKNAME=myticks, XTICKV=mytickvals,color=black,
> CHARTHICK=3, CHARSIZE=1.3
> AXIS, YAXIS=0, TICKLEN=myticklen,YTICKS=8, YTICKNAME=myticks1,
> YTICKV=mytickvals1,color=black,CHARTHICK=3, CHARSIZE=1.3
>
> Any more ideas??


Get rid of the NORMAL keyword and add some LOG keywords.
Set some ranges on your axes. Spend a couple of minutes
thinking about what you are trying to do. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Reply With Quote
  #8  
Old 09-08-2008, 12:15 PM
maffie
Guest
 
Default Re: fit image to logarithmic color bar

Well, I am thinking about already a long time actually, and it doens't
seem to bring what I was hoping for.

The idea of the axis is to plot axis which solely define classes, like
for example variable names, without any other reference to the values
plotted in the plot itself. So I just want to draw a line with a
number of ticks which are denoted by their variable name.

The strange thing hereby is that I can not see the axis, or axis title
or any other information from the axis...
Reply With Quote
  #9  
Old 09-08-2008, 12:28 PM
David Fanning
Guest
 
Default Re: fit image to logarithmic color bar

maffie writes:

> Well, I am thinking about already a long time actually, and it doens't
> seem to bring what I was hoping for.
>
> The idea of the axis is to plot axis which solely define classes, like
> for example variable names, without any other reference to the values
> plotted in the plot itself. So I just want to draw a line with a
> number of ticks which are denoted by their variable name.
>
> The strange thing hereby is that I can not see the axis, or axis title
> or any other information from the axis...


Well, if we have eliminated everything else, then I would
say drawing white on white is a good possibility. I'm not
sure why everyone and his brother appears to think GhostView
is the best display device these days, but there are color
problems to watch out for in PostScript. Specifically,
don't use the color indices 0 or 255 to specify *any*
of your colors. Try defining a magenta color at color index
128 and then use that to draw your axis. See anything now?

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Reply With Quote
  #10  
Old 09-08-2008, 12:54 PM
maffie
Guest
 
Default Re: fit image to logarithmic color bar

I have changed my color black to magenta on index 128 as you
suggested, but this doesn't help. I don't really understand. I have
plotted a lot of information on one page (plots, colorbar, some text
information....), in the colors I like it to be, and all is visible. I
just can't seem to get the axis appearing, although it was there when
I ran my script yesterday. And this is the most bizarre thing to me?

Maybe I should just try to plot the variables name with XYOUTS as a
string, on the location I want them to be on? As there is no direct
relation with the values shown in the plot...
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:39 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.