MATLAB: Plot MarkerSize units normalized

markersizenormalizedplotunits

Hello! I need to plot a lot of circle of a precise size every small time-step. I was using a for with plot rcos-rsin, but it was very slow. Then I tried scatter that was very faster, but finally I used plot with 'o' parameter and MarkerSize set, that is absolutely the fastest solution. The only problem I have is the size of the marker, that never matches with what I suppose to. I tried changing 'units' to 'normalized' to both gca and gcf, but it doesn't seem to affect the MarkerSize option.
So, how do I get MarkerSize proportional to axes? Thank you.

Best Answer

Sorry, the MarkerSize is always in points.
curunits = get(gca, 'Units');
set(gca, 'Units', 'Points');
cursize = get(gca, 'Position');
set(gca, 'Units', curunits);
Now cursize(3) is the width in points and cursize(4) is the height in points. You can then calculate an appropriate marker size as a fraction of the axes size. If you want to catch changes in the axes size, hook into the figure ResizeFcn callback.