thank you in advance
Marwa
Do you want the colormap to be linear in the log scale? If so you could use real2rgb (http://www.mathworks.com/matlabcentral/fileexchange/23342) to generate the log scale texture map as follows:
% Generate data
[X Y Z] = peaks(50);
Z = abs(Z) * 100 + 1;
% Generate log-scale texture
T = real2rgb(log(Z), 'jet');
% Render the surface
surf(X, Y, Z, T);
set(gca,'Zscale','log','Clim',[min(Z(:)) max(Z(:))]);
% Generate the colorbar
colormap jet;
Hi,
thank you, your example is very nice, and exactly what I want
but, my matrix is not square like matrix in your example,for that reason, it dosenot work in my work,
if you have solution, give me it please
size(x)=40X1
size(y)=2X1
size(Z)=2X40
thank you in advance
Any size of matrix works for me. In the example below my matrices are the same size as yours:
% Generate data
[X Y Z] = peaks(40);
Z = abs(Z) * 100 + 1;
% Resize the data to be rectangular
X = X(1,:);
Y = Y(1:2,1);
Z = Z(1:2,:);
Incidentally, this should be possible without using real2rgb, but I can't quite get it to work. Here is my attempt:
% Generate data
[X Y Z] = peaks(50);
Z = abs(Z) * 100 + 1;
% Render the surface
surf(X, Y, Z, log(Z));
set(gca,'Zscale','log');
% Generate the colorbar
colormap jet;
h=colorbar;
lims = [min(Z(:)) max(Z(:))];
set(get(h, 'children'), 'Ydata',lims);
set(h,'YScale','log', 'Ylim', lims);
%%%%%%%%%%%%%%%%%%%%%%%55
Hallo,
Thank you again for you quick reply,the log scale (trick label) of the 3D surf is not the same for color bar, this is the problem
The colorbar colors and values (i.e. tick labels) coincide with the colors and Z values of the surface using the code from my first example. What more do you want? Please be as explicit as you can.
Hallo,
Many thanks, it works,
thank you Oliver
Regards
Marwa
Oliver,
I have been unable to get your solution to work out for using a filled contour plot instead of a surf plot because the different inputs.
I have however figured out how to get the plots to work right using multiple axes.
It looks a bit screwy in the matlab figure, but the Jpg it generates looks fine. If anybody finds this thread and can help me clean it up a bit, I would appreciate it. I am new to using axes and handle lables, so I might be doing some unnecessary steps
% x data in x_scale, y data in y_scale and z data in z2
figure1 = figure('Name','fbw2');
% Create axes
axes1 = axes('Visible','off','Parent',figure1,'CLim',[min(z2) max(z2)]);
% Create axes
axes2 = axes('Parent',figure1,'Layer','top');
box(axes2,'on');
hold(axes2,'all');
% Create contour
contour(x_scale,y_scale,log(z2),200,'LineStyle','none','LineColor',[0 0 0],...
'Fill','on',...
'Parent',axes2);
% Create colorbar
cb1 = colorbar('peer',axes2,'YScale','log','YMinorTick','on','FontSize',14);
% Create colorbar
cb2 = colorbar('peer',axes1,'YScale','log','YMinorTick','on','FontSize',14);
axis tight
set(gca, 'FontSize',14)
colorbar(cb1,'delete')
saveas(figure1,'log_fbw.jpg')