Setting a Colormap To An Errorbar Plot
조회 수: 2 (최근 30일)
이전 댓글 표시
Hey guys, I was a just wondering if it's possible set a colormap like 'jet' to an errorbar plot. I found one place that already can do this with a for loop
c = jet(length(x)) ;
figure;
hold on
for k = 1:length(x)
e1 = errorbar(x(k),y(k),dy(k),'x');
set(e1,'Color',c(k,:))
set(e1,'MarkerEdgeColor',c(k,:))
end
but is there anyway to do this directly with linespecs like "MarkerFaceColor"? Thanks in advance!
답변 (1개)
DGM
2022년 11월 15일
As far as I know, the answer is no. The documentation and error messaging supports this assertion. It should not be surprising, as tools like plot() don't support the behavior either.
Are there undocumented methods? Maybe. I can't seem to get anywhere with it though.
n = 20;
x = linspace(0,2*pi,n);
y = sin(x);
dy = 0.1*randn(1,n);
% map must be 4xN, uint8
rgbamap = im2uint8([jet(n) ones(n,1)]).';
% plot the thing
heb = errorbar(x,y,dy,'x');
% try to manipulate undocumented descendant objects
hmark = heb.MarkerHandle; % a marker object
hbar = heb.Bar; % a linestrip object
hmark.EdgeColorBinding = 'interpolated'; % this works
hmark.EdgeColorData = rgbamap;
%hbar.ColorBinding = 'interpolated'; % but this won't
%hbar.ColorData = rgbamap;
So I can colormap the X markers, but not the bars or the caps. I don't know if I'm specifying these properties wrong or if it's just a limitation. It's not like there's documentation for this. Make of it what you will.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Errorbars에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!