I want to represent a set of 2-D experimental data (1 x 10matrix) using a colorbar plot.
Show older comments
I want to represent a set of 2-D experimental data (1 x 10matrix) using a colorbar plot where y reamins constant and the experimental value changes according to the x cordinate. I am attaching a sample plot i want to make. Also i am attaching the code I tried to do this.
x = [20 22 26 34]; % Random data
y = [0 4 6];
C = [0 1 2 3 ; 1 2 3 4 ; 2 3 4 5];
xSplit = diff(x)/2; % Find edge points
ySplit = diff(y)/2;
xEdges = [x(1)-xSplit(1) x(2:end)-xSplit x(end)+xSplit(end)];
yEdges = [y(1)-ySplit(1) y(2:end)-ySplit y(end)+ySplit(end)];
[XGrid, YGrid] = meshgrid(xEdges,yEdges);
YGrid = flipud(YGrid); % To match expected behavior
C = [[C zeros(size(C,1),1)] ; zeros(1,size(C,2)+1)];% Last row/col ignored
pcolor(XGrid,YGrid,C)
hold on % Plot original data points
[X,Y] = meshgrid(x,y);
Y = flipud(Y);
plot(X,Y,'or')
Accepted Answer
More Answers (0)
Categories
Find more on Colorbar in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!