How to plot data where one variable is represented by color intensity?

4 views (last 30 days)
Data is of this type:
X=1:2204;
Y=[1995 1996 1997 1998 19990];
Z=[23 5 46 8 24 656 .........2204 values;
......................................;
......................................;
......................................;
.......................................]
X- represnts 2204 candidate, like candidate 1 candidate 2
Y- I have data of these candidate of five years
Z- each row representing data of one year.
I want to plot this data in five strips, where color intensity in any strip gives us value of z corresponding to that year.
Output should look like as shown in figure:

Accepted Answer

Image Analyst
Image Analyst on 13 Dec 2014
Try this:
columns = length(Z);
rows= round(max(Y) - min(Y));
output = zeros(rows, columns);
for row = 1 : rows
thisRow = y(row) - min(Y) + 1;
for col = 1 : length(Z)
output(thisRow, col) = z(col);
end
end
imshow(output, []);
colormap(winter(256));
  4 Comments
Himanshu Tyagi
Himanshu Tyagi on 13 Dec 2014
Edited: Image Analyst on 13 Dec 2014
[ndata, text, alldata]=xlsread('Y_for bar chart.xlsx');
alldat=(alldata)';
z=cell2mat(alldat);
x=1:2204;
y=1:5;
This is the data on which i am working on. Thanks in advance.
Image Analyst
Image Analyst on 13 Dec 2014
[ndata, text, alldata]=xlsread('Y_for bar chart.xlsx');
allData = ndata';
[rows, columns] = size(allData)
resizedData = imresize(allData, [columns, columns], 'nearest');
imshow(resizedData, []);
axis on;
% Create and apply colormap.
colorMap = ones(256, 3);
colorMap(:, 1) = linspace(1, 0, 256);
colorMap(:, 2) = linspace(1, 0, 256);
colorMap(:, 3) = 1;
colormap(colorMap)
xlabel('Candidate');
ylabel('Year');
colorbar;

Sign in to comment.

More Answers (0)

Categories

Find more on Colormaps in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!