필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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 CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by