Bar plot with color map

조회 수: 25 (최근 30일)
Rotem Katzir
Rotem Katzir 2018년 6월 26일
답변: Ahmad Gunawan 2019년 8월 12일
I have a table with x rows and two columns: fold change and p-value. I'd like to make a bar plot such that the length of the bars will be according to the fold change value, and the color of each according to it's p-value (therefore colormap should be presented as well)
I couldn't figure out how i can do such thing, so if it's indeed possible on Matlab i would appreciate your help. Thanks!
  댓글 수: 1
Stephen
Stephen 2019년 6월 26일
Did you ever solve this problem or get an answer? I have a similar question and can't find a solution. I agree that the page suggested by Walter Roberson did not answer this.

댓글을 달려면 로그인하십시오.

답변 (3개)

Ahmad Gunawan
Ahmad Gunawan 2019년 8월 12일
Example to reproduce:
clear all
close all
Year = [2010:2021];
Data = [0.97 1.22 1.4 1.59 1.91 2.14 2.28 2.48 2.65 2.82 2.96 3.09];
b=bar(Year, Data, 'FaceColor','flat');
cmap = colormap(jet);
for k = 1:length(Data)
b.CData(k,:) = cmap(5*k,:);
end
grid on;
xlabel('Year');
ylabel('Number of Users (Billions)');
% text(1:length(Data),Year,num2str(Data'),'vert','bottom','horiz','center');
text(Year, Data, num2str(Data'), 'vert','bottom','horiz','center')
box off
set(gca,'Position',[0.1 0.1 0.87 0.7])
print('-dpng','-r300','users.png');

Walter Roberson
Walter Roberson 2018년 6월 26일

Rotem Katzir
Rotem Katzir 2018년 6월 26일
hi, thanks for your help. i already visited this page and i don't think it helps me with what i want. please see an example for the kind of graph i'd like to get
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 6월 26일
barh() for horizontal bars.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by