How to apply an RGB color wave to a surface plot.
Hiroto
Hi All
I am having trouble with how to change the color of the surface plot of a 2D matrix wave (MxN).
Igor has preset colors for Surface plots, but I want to apply color waves from ColorWaveTables to Surface plots instead of preset colors.
The manual notes that the MxN 2D wave requires the MxNx4 color wave, but I can't find out how to make the three-column RGB color wave the type of wave to apply to Surface Plot.
I want to use spectral colors for Surface Plot, but what should I do?
Thank you
Hiroto
It seems like you are talking about Gizmo plots. In that case I have written a small function which creates a 4D color wave out of one of the preset tables:
variable doLog = ParamIsDefault(logColor) ? 0 : logColor
variable doZero = ParamIsDefault(fromZero) ? 0 : fromZero
variable doAlpha= ParamIsDefault(alpha) ? 1 : limit(alpha, 0, 1)
string colorListName = "Rainbow"
if (!ParamIsDefault(colors) && WhichListItem(colors,CTabList())>-1)
colorListName = colors
endif
ColorTab2Wave $colorListName; wave M_colors
int i,j, num = DimSize(M_colors,0)-1
WaveStats/Q in; variable wMax = V_max, wMin = V_min*(doZero>0)
Make/O/N=(DimSize(in,0),DimSize(in,1),4) $(NameOfWave(in)+"_color")/Wave=colorW=doAlpha
for (i=0; i<DimSize(in,0); i++)
for (j=0; j<DimSize(in,1); j++)
variable whichColor
if (doLog)
whichColor = log((in[i][j]-wMin)/(wMax-wMin)*9+1)
else
whichColor = (in[i][j]-wMin)/(wMax-wMin)
endif
whichColor = numtype(whichColor) != 0 ? 0 : whichColor
whichColor = round(whichColor*num)
colorW[i][j][0,2] = M_colors[whichColor][r]/65535
endfor
endfor
KillWaves/Z M_colors
end
Use as:
GizmoColorWave(yourInputData,colors=AcolotTableNameString)
At least this should give you an idea how to create your own color-table waves.
July 23, 2024 at 10:41 pm - Permalink
Gizmo supports the creation of color waves using the ModifyGizmo command with:
makeColorWave={srcWave, cTabName, isInverse }
Here is an example:
Modifygizmo makeColorWave={ddd, Spectrum, 0 } // use the Spectrum color table
// The created color wave is called ddd_c. It is applied using the
// following two commands:
ModifyGizmo ModifyObject=sampleSurface,objectType=surface,property={ surfaceColorType,3}
ModifyGizmo ModifyObject=sampleSurface,objectType=surface,property={ surfaceColorWave,root:ddd_C}
I hope this helps,
AG
July 24, 2024 at 01:48 pm - Permalink
Hi All
>>chozo
Thank you for sharing Igor macro.
Here's a question: What should I input into 'AcolotTableNameString' in this macro?
>>Igor
Thank you for the useful information.
This method converts CTablist colors into waves.
One more question, is there a way to make any Nx3 color wave apply to Gizmo Surface Plot?
I want to apply colors not bult-in Igor, which is not in CTablist, to Surface Plot, but I just can't figure out how to do it.
For example, could I apply the color wave from ColorTableWave to the Surface Plot?
Thank you
Hiroto
July 24, 2024 at 07:12 pm - Permalink
AColorTableNameString was meant to be a string containing a name of a supported color table, such as "Rainbow". But anyway, it seems you want to use your own color wave. For this, I have slightly modified my script:
variable doLog = ParamIsDefault(logColor) ? 0 : logColor
variable doZero = ParamIsDefault(fromZero) ? 0 : fromZero
variable doAlpha= ParamIsDefault(alpha) ? 1 : limit(alpha, 0, 1)
int i,j, num = DimSize(colors,0)-1
WaveStats/Q in; variable wMax = V_max, wMin = V_min*(doZero>0)
Make/O/N=(DimSize(in,0),DimSize(in,1),4) $(NameOfWave(in)+"_color")/Wave=colorW=doAlpha
for (i=0; i<DimSize(in,0); i++)
for (j=0; j<DimSize(in,1); j++)
variable whichColor
if (doLog)
whichColor = log((in[i][j]-wMin)/(wMax-wMin)*9+1)
else
whichColor = (in[i][j]-wMin)/(wMax-wMin)
endif
whichColor = numtype(whichColor) != 0 ? 0 : whichColor
whichColor = round(whichColor*num)
colorW[i][j][0,2] = colors[whichColor][r]/65535
endfor
endfor
end
Run as follows:
GizmoColorWave(yourPlottedData, YourColorWave)
The optional settings are:
The provided color wave must contain values from 0 to 65535.
July 24, 2024 at 08:50 pm - Permalink
Thank you!
That was exactly what I wanted to do.
I really appreciate your help.
July 26, 2024 at 01:49 am - Permalink