Setting a Colormap To An Errorbar Plot
조회 수: 10(최근 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)) ;
for k = 1:length(x)
e1 = errorbar(x(k),y(k),dy(k),'x');
but is there anyway to do this directly with linespecs like "MarkerFaceColor"? Thanks in advance!
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.