rgba color table
SergioLAlvarez
I have been struggling to change the colorscale of a Gizmo scatter plot. I am using Windows version Igor 6.2.2.2. I have viewed the tutorial videos and read some of the responses to similar questions as mine in IgorExchange. I plotted the 3D scatter plot and created a color wave using "ModifyGizmo makeTripletColorwave = {hcho_ppbv_10s, rainbow,1}". As I undersand this sets the rainbow colortable to a built in colorrange based on a specified wave (e.g. hcho_ppbv_10s). I have attached the pxp file so you can take a look.
If I can't change the built-in table easily, how can I make a color table myself? Making a table myself would be very timeconsuming on a point by point basis since I have 1807 rows. Is it possible to export a rainbow colortable from a 2d plot where there is an option to change the first and last color range? It would be nice to have that option in 3D Gizmo plots. Any help would would be appreciated.
Sergio
You have complete control over the color of scatter objects via the color wave, e.g., HCHO_ppbv_10s_C. I added to Gizmo makeTripletColorwave as a convenience function to handle the typical case where an auxiliary wave is used to determine the color information. If you want to get a color wave that uses different rules (other than linear scaling) you can use the following approach:
1. Choose one of the internal color tables, e.g., rainbow.
2. Use the command ColorTab2Wave. This will create M_Colors
3. Determine how many colors are in the table using DimSize(M_Colors,0)
4. Scale the colors so that they work in Gizmo:
Redimension/S M_Colors
M_Colors/=65535.
5. At this point you have to apply your own rules. For example, if you want the resulting color wave to have a fixed color rgbaMin for input values below minVal and rgbaMax for input values above maxVal and linearly map M_Colors in between you could use a loop like:
Wave scaleWave,M_Colors
Variable minVal,maxVal
variable numColors=DimSize(M_Colors,0)
Variable i,rows=DimSize(scaleWave,0)
Make/O/N=(rows,4) outColorWave=1 // set the alpha
Make/N=4 rgbaMin={0,0,0,1} // for example
Make/N=4 rgbaMax={1,0,0,1} // for example
Variable val,count=0,index
Variable scaleMin=WaveMin(scaleWave)
Variable scaleMax=WaveMax(scaleWave)
Variable nor=numColors/(scaleMax-scaleMin)
for(i=0;i<rows;i+=1)
val=scaleWave[i]
if(val<minVal)
outColorWave[count][]=rgbaMin[q]
elseif(val>maxVal)
outColorWave[count][]=rgbaMax[q]
else
index=(scaleWave[i]-scaleMin)*nor
outColorWave[count][0]=M_Colors[index][0]
outColorWave[count][1]=M_Colors[index][1]
outColorWave[count][2]=M_Colors[index][2]
endif
count+=1
endfor
End
Looking at your experiment I noticed that you have NaNs in your scaling wave so you need to decide how to handle them. Your options are to completely eliminate the corresponding scatter point or to set it's alpha to zero (but you'd have to make sure that you enabled blending).
I hope this helps,
A.G.
WaveMetrics, Inc.
December 13, 2011 at 04:04 pm - Permalink
December 15, 2011 at 11:44 am - Permalink
I tried the MakeMyColorWave function. It worked. However, I am not sure if I used the correct maxVal and minVal. Was I suppose to use the minimum value and maximum value of my of the HCHO_ppbv_10s wave. For the scalewave I used hcho_ppbv_10s_c. The following is what I typed in the command line:
ColorTab2Wave rainbow
Variable N= DimSize(M_colors,0)
Redimension/S M_Colors
M_Colors/=65535
makeMyColorWave(hcho_ppbv_10s_c,M_Colors,0,6)
Then, I selected outcolorwave to be used as colorwave, instead of hcho_ppbv_10s_c. I went ahead and removed the nan data points from the scatter plot. I have attached the image so you can take look. I got to0 many red data points.
I am not sure if I explained myself well in the previous comment. Just like plotting a 2d plot with color as f(z), I want to be able to set the first color as the minimum value and the last color as the maximum value of hcho_ppbv_10s wave which is a concentration in may case. I just want to be able to bring out areas of high concentrations that do not show along the flight path which do not show if auto (or default which uses the max and min values automatically) is selected. Thank you for your help.
Sergio
December 15, 2011 at 11:43 am - Permalink
When you use "ModifyGizmo makeTripletColorwave" it makes a linear mapping between the range of data in your scaling wave and the colors in the table. In my earlier response I was under the impression that you wanted to change "the first and last colors". The procedure that I wrote allowed you to do just that. The idea is that if your scaling wave data range between [smin,smax] you can provide two values smin2 and smax2 such that sminsmax2. Then you call the function makeMyColorWave(scaleWave,M_Colors,smin2,smax2) and get rgbaMin for all points where the scaling wave is in the range [smin,smin2] and rgbaMax for [smax2,smax] and the rest of the rainbow colortable distributed linearly in the range [smin2,smax2].
In your last post you said:
... which is exactly what you get using makeTripletColorwave.
It might best if you contacted support@wavemetrics.com with a copy of your experiment, contact information and full details of what you want to accomplish.
A.G.
WaveMetrics, Inc.
December 15, 2011 at 01:38 pm - Permalink