Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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 comentario
Guillaume
Guillaume el 23 de Abr. de 2018

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.

Iniciar sesión para comentar.

Respuestas (1)

Paul Smits
Paul Smits el 4 de Abr. de 2019
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.

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by