Borrar filtros
Borrar filtros

Setting a Colormap To An Errorbar Plot

5 visualizaciones (últimos 30 días)
tiwwexx
tiwwexx el 12 de Jul. de 2019
Respondida: DGM el 15 de Nov. de 2022
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!

Respuestas (1)

DGM
DGM el 15 de Nov. de 2022
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.

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by