edge colordata property attempts to set are inconsistent

1 回表示 (過去 30 日間)
Jeff
Jeff 2016 年 7 月 15 日
コメント済み: Walter Roberson 2016 年 7 月 15 日
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 件のコメント
Jeff
Jeff 2016 年 7 月 15 日
Jeff
Jeff 2016 年 7 月 15 日
I'm running 2015b

サインインしてコメントする。

採用された回答

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?
Walter Roberson
Walter Roberson 2016 年 7 月 15 日
patches support EdgeAlpha and FaceVertexAlphaData properties

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by