edge colordata property attempts to set are inconsistent

4 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

采纳的回答

Kelly Kearney
Kelly Kearney 2016-7-15
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 个评论
Jeff
Jeff 2016-7-15
编辑:Jeff 2016-7-15
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Polygons 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by