Setting a Colormap To An Errorbar Plot

2 vues (au cours des 30 derniers jours)
tiwwexx
tiwwexx le 12 Juil 2019
Réponse apportée : DGM le 15 Nov 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!
  1 commentaire
Lina Koronfel
Lina Koronfel le 15 Nov 2022
Did you get an answer?

Connectez-vous pour commenter.

Réponses (1)

DGM
DGM le 15 Nov 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.

Catégories

En savoir plus sur Errorbars dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by