How to match colorbar with colormap ranges in surf?
3 views (last 30 days)
Daniel Melendrez on 2 Sep 2022
I have a data set that contains values from a certain electronic circuit (voltages (VL), currents (io) and Load resistances (RL)). The size of these arrays is 10x10(x6). (EDITED. I mistakently said 5 times before)
The following code creates the result shown below:
for vsPtr = 1:numel(Vs) % This loop runs 6 times (EDITED. I mistakently said 5 times before)
io_V1_mat = repmat(io(:, vsPtr), [1,points])';
subplot(3, 2, vsPtr)
cm = colormap(parula(points));
srf = surf(io_V1_mat,RL_mat, VL(:,:,vsPtr) ); % do I need to insert a 4th argument with the cm that I need?
cb = colorbar;
set(cb, 'ylim', [min(min(VL(:,:, vsPtr))) max(max(VL(:,:,vsPtr)))]);
cb.Label.String = 'Load Resitance Node Voltage';
cb.Label.FontSize = 12;
srf = gca;
srf.YScale = 'log';
srf.XScale = 'log';
srf.XLabel.String = 'Iout [A]';
srf.YLabel.String = 'RL [Ohms]';
srf.Title.String = sprintf('Vs = %0.1f V', Vs(vsPtr));
My question is:
How on earth can I assign the color range from the colobars to the colormap of each plot? (look at the correspondence I am referring to here: I want to assign the color gradient shown in the colorbar to the colormap from each surf plot).
I have tried every proposed solution here in Mathworks without success (pulling my hair here tbh)
Kevin Holly on 2 Sep 2022
surf(io_V1_mat,RL_mat, VL, VL )% The fourth input is your values that correspond with the color map
caxis([0 2000])% You can also change the limits of your colormap.