edge colordata property attempts to set are inconsistent

2 vues (au cours des 30 derniers jours)
Jeff
Jeff le 15 Juil 2016
Commenté : Walter Roberson le 15 Juil 2016
The following section of code works fine when I manually enter them one at a time on the command line, or run the m file with a stop at the set line, and then step past the line.
It doesn't work however if I simply let the m file run completely with a pause. What am I doing wrong?
figure('Position',[166 325 1205 755])
h = plot(gps(:,1),gps(:,2),'r');
spd = a(spdChan).Data(ind);
cmap = colormap;
cmapX = [min(spd):(max(spd) - min(spd))/(size(cmap,1)-1):max(spd)]';
tmp = interp1(cmapX,cmap,spd);
interpCmap = cast([255*tmp 255*ones(size(tmp,1),1)]','uint8');
set(h.Edge, 'ColorType','truecoloralpha', 'ColorBinding','interpolated', 'ColorData', interpCmap);
  5 commentaires
Jeff
Jeff le 15 Juil 2016
Jeff
Jeff le 15 Juil 2016
I'm running 2015b

Connectez-vous pour commenter.

Réponse acceptée

Kelly Kearney
Kelly Kearney le 15 Juil 2016
I've found that messing around with some of the undocumented properties of new graphics objects can be finicky, with properties resetting to their original values later, or failing to change when run in a script (as you're seeing). I recommend only resorting to this sort of hacking when you can't find any workarounds using the documented properties.
Luckily, there's an easy workaround for color-changing lines, and it eliminates the need to do the color interpolation manually: use a patch instead.
x = [0:.01:20];
y = [0:.01:10 9.99:-.01:0];
hln = patch([x NaN], [y NaN], [y NaN]);
set(hln, 'edgecolor', 'interp');
  2 commentaires
Jeff
Jeff le 15 Juil 2016
Modifié(e) : Jeff le 15 Juil 2016
Thanks, I hadn't thought of that. I was also planning on using transparency as a crude 4th dimension. I'll have to research this more to see if I can also control that as well?
Walter Roberson
Walter Roberson le 15 Juil 2016
patches support EdgeAlpha and FaceVertexAlphaData properties

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Color and Styling dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by