Is there a way to plot (4D) such that x, y, and z are in the linear scale but the fourth dimension is logarithmic?

4 Ansichten (letzte 30 Tage)
I am having problems plotting a 243,082 row, 4 column data set. I want to display some amplitude values at specific times. I have x coordinates on the x axis, y coordinates on the y axis, time on the z axis, and want amplitude displayed by color at each time. I have been trying to use the scatter3 command to display the data, and everything displays correctly except for the amplitude (all the amplitudes are blue). I think part of the problem may be the fact that the amplitudes range from 10^-27 to 10^-6 and so MATLAB is just rounding each value to zero. Is there a way to make the amplitude display in the logarithmic scale? And will that fix the problem?
Here is my code:
file=uigetfile;
x_coordinate=xlsread(file,'a2:a243082');
y_coordinate=xlsread(file,'b2:b243082');
time=xlsread(file,'c2:c243082');
amplitude=xlsread(file,'d2:d243082');
figure
scatter3(x_coordinate,y_coordinate,time,amplitude)
caxis([10^(-27) 10^(-6)])
colorbar

Akzeptierte Antwort

John Barber
John Barber am 7 Jul. 2013
Deven,
As far as I know, the color axis cannot be directly set to log-scale, unlike the three coordinate axes. However, you can log-transform the color data yourself and get the same result with a bit of work. To get the colorbar to work out, one approach is to first log-transform the data, then rescale the transformed data to fit the same range as the original data. You can then set the colorbar to use log-scaling, and the result will be log-scaled coloring, with the correct scale shown on the colorbar.
Here is some sample code:
% Get the min and max of the unscaled data
minC = min(C(:));
maxC = max(C(:));
% Log-transform and scale the data
Cscaled = minC + (maxC-menC)*(log10(C) - log10(minC))/(log10(maxC/minC));
% (plot using the scaled data)
% Make a log-scaled colorbar
hCbar = colorbar;
set(hCbar,'Yscale','log');
You can also take a look at the code in my File Exchange program logzplot: http://www.mathworks.com/matlabcentral/fileexchange/29317.
- John

Weitere Antworten (0)

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by