2D Histogram
Marti
I have a problem to create 2D histogram. I have two data sets: ISIs in ms (0-500 ms, 250 bin, 250 ms binsize; Vm -60- -45mV, 250 bin, 0.1mV binsize) I've tried the commands below:
•make/n=(250,250) myHist
•setscale x,0,500,myHist
•setscale y,-60,-45, myHist
JointHistogram(data1,data2,myHist) or Function JointHistogram(data1,data2,myHist)
but I have an error message. Can anyone help?
Thanks,
Having done that, I was able to successfully execute these commands:
Make /O /N=1000 yData = -60 + (15*p/1000)
Make /O /N=(250,250) myHist
SetScale x,0,500,myHist
SetScale y,-60,-45, myHist
JointHistogram(xData,yData,myHist)
NewImage myHist
June 11, 2012 at 05:56 pm - Permalink
Yes, thank you very much. Meantime I have found my mistake in the function as well. It works fine in my case too and I got a nice contour plot. I have an other question. How can I normalise the matrix of the results of the 2D Histogram?
Also if I would like to represent the 'density' or the number of dots in each bins and I apply the contour plot how can I set values for the z axe and represent in 3D graph?
Thank you very much for your help,
Marti
June 12, 2012 at 03:14 am - Permalink
You have not defined what you mean by normalization. If you only want the output to sum to 1 then execute:
Variable sss=sum(matrix2d)
Duplicate/O matrix2d,normalized2d // never modify the original
normalized2d/=sss
You are not telling us what kind of a 3D graph you want to plot: do you want to plot a surface, a scatter or maybe some kind of a 3D bar chart?
A.G.
WaveMetrics, Inc.
June 12, 2012 at 01:05 pm - Permalink
Thank you very much for your help, the normalization works fine.
I'm sorry if I wasn't enough precise, I meant the surface plot as a 3D graph. But you are right the 3D bar chart can be interesting as well.
Thanks,
June 13, 2012 at 02:55 am - Permalink
I managed to create the surface plot as well. Thanks!!!!
Marti
A.G.
WaveMetrics, Inc.[/quote]
June 13, 2012 at 03:49 am - Permalink
Typically histograms are plotted in a bar-chart mode (although that is partly a matter of taste). AG was perhaps too modest to mention his Gizmo3DBarChart.ipf that comes with Igor, in the Wavemetrics Procedures:Gizmo Procedures folder.
If you don't care for the spacing between bars, then a surface plot will do. Be aware however that standard surface plots interpolate over the grid. If you want flat-topped bins of the histogram in a surface mode, AG had sent me the following procedure for converting to a parametric surface wave:
Wave inWave
Variable rows=dimSize(inWave,0)
Variable cols=dimSize(inWave,1)
Variable i,j,val
Make/N=(2*rows,2*cols,3)/O paramWave
// fill the x-values
Variable x0=dimOffset(inWave,0)
Variable dx=dimDelta(inWave,0)
Variable curx=x0
for(i=0;i<rows;i+=1)
paramWave[2*i][][0]=curX
paramWave[2*i+1][][0]=curX+dx
curX+=dx
endfor
// fill the y-values
Variable y0=dimOffset(inWave,1)
Variable dy=dimDelta(inWave,1)
Variable cury=y0
for(i=0;i<cols;i+=1)
paramWave[][2*i][1]=curY
paramWave[][2*i+1][1]=curY+dy
curY+=dy
endfor
// fill the z-values
for(i=0;i<rows;i+=1)
for(j=0;j<cols;j+=1)
val=inWave[i][j]
paramWave[2*i][2*j][2]=val
paramWave[2*i+1][2*j][2]=val
paramWave[2*i][2*j+1][2]=val
paramWave[2*i+1][2*j+1][2]=val
endfor
endfor
End
June 13, 2012 at 04:36 am - Permalink