Matching scatter marker size to pixel size
Show older comments
I'm trying to set the size of markers in my scatter plot to the size of a pixel in my plot. At the moment, I'm calculating the marker size using the following code:
% Setting the size of square markers to 1px^2
s=1.0;
currentunits = get(gca,'Units');
set(gca, 'Units', 'Points');
axpos = get(gca,'Position');
set(gca, 'Units', currentunits);
markerWidth = s/diff(xlim)*axpos(3); % Calculate Marker width in points
s = markerWidth^2;
So, I'm adjusting the value of s from 1 px to its size in points^2, which is how the marker size is defined. But the output is not quite giving me what I want:

What's going on here? Why are the marker sizes still smaller than the image sizes?
4 Comments
Adam Danz
on 24 Oct 2019
Do you want pixel units (as stated in your question title) or point units (as stated in your question)? A point is 1/72 of an inch. On Mac's a pixel is also 1/72 but on windows a pixle is 1/96 of an inch.
Sam Nadjari
on 24 Oct 2019
Sam Nadjari
on 24 Oct 2019
Sam Nadjari
on 24 Oct 2019
Accepted Answer
More Answers (0)
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

