フィルターのクリア

Skript for transparent markers works in debugger stepwise mode but not as a whole skript

1 回表示 (過去 30 日間)
Janic Deplazes
Janic Deplazes 2018 年 4 月 23 日
回答済み: Paul Smits 2019 年 4 月 4 日
Hey guys, I've written a script that plots dots in different sizes for different categories of data. I would now like to add some transparency to the dots to be able o better see the underlying colors. I've simplified my script like this:
h1 = plot([1:20],[1:20],'.', 'MarkerEdgeColor', [0 0 0], 'MarkerSize', 5);
hMarkers = h1.MarkerHandle;
hMarkers.EdgeColorData = uint8(255*[0;0;0;0.6]);
h2 = plot([1:20],[1:20],'.', 'MarkerEdgeColor', [0 0 0], 'MarkerSize', 2.5);
hMarkers = h2.MarkerHandle;
hMarkers.EdgeColorData = uint8(255*[0;0;0;0.6]);
It works when I'm in the debugger-mode and do it step by step but it won't work when I run the whole skript. Has anybody got an idea why?
Thanks a lot for your help. Cheers
  1 件のコメント
Guillaume
Guillaume 2018 年 4 月 23 日

MarkerHandle is a hidden non documented property of line objects. Since it's not documented, matlab is free to do whatever it wants with it and yes, it does look like it's only updated at times, not instantly.

Even if your code worked in your current version, there'd be no guarantee that it work in the next version. You'd be better off finding an official method of doing what you want. Unfortunately, I'm not familiar enough with graphics to tell you what that is.

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

回答 (1 件)

Paul Smits
Paul Smits 2019 年 4 月 4 日
Matlab optimisation somehow destroys proper marker definitions.
Hack-solution: pause between creating the plot and fetching the markers.
h1 = plot([1:20],[1:20],'.', 'MarkerEdgeColor', [0 0 0], 'MarkerSize', 5);
pause(0.0000000001);
hMarkers = h1.MarkerHandle;
h2 = plot([1:20],[1:20],'.', 'MarkerEdgeColor', [0 0 0], 'MarkerSize', 2.5);
pause(0.0000000001);
hMarkers = h2.MarkerHandle;
hMarkers.EdgeColorData = uint8(255*[0;0;0;0.6]);
Is it dumb? Yes. Does it work? Yes.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by