Assign a specific Value to Marker Size in relation with axes

9 views (last 30 days)
im trying to plot circles horizontally with specific spacing ,adjusting the radius of marker size doesnt work because i want it in relation with axes unit, in micro meter to be specific
here is the code:
w = 10; %e-6 Beam radius in µm
frep = 100e3; % kHz Pulse repetition frequency.
T = 1/frep; %1/s Timelapse between 2 Pulses
vscan = 1000e-3; %m/s Scan velocity
dP = vscan*T;%m Spacing between two Circles
slx = 0.0001; %m Scan length in x-axis.
NxL = int16(slx/dP); % Number of Circles in x-axis
xL = double((0:NxL))*dP; %m
dL = 100e-6; %m Linienabstand
NyL=10;
yL = (0:NyL)*dL; %m
hold on
for ix = 1:NxL %Scan in x-Richtung
plot(xL(ix),yL(NyL/2),'ro','Markersize',w)
end
hold off
  2 Comments
Simon Chan
Simon Chan on 27 Feb 2022
Do you want something like the following?
If yes, you can assign the marker size for each plot.
for ix = 1:NxL %Scan in x-Richtung
plot(xL(ix),yL(NyL/2),'ro','Markersize',100000*xL(ix)+1);
hold on
end
Hussam Saddour
Hussam Saddour on 27 Feb 2022
actually not ,i want to adjust the marker size radius in Meters,so that all circles on the same scale as of the axis (not in pixels) which is default to matlab

Sign in to comment.

Accepted Answer

Voss
Voss on 27 Feb 2022
Edited: Voss on 27 Feb 2022
MarkerSize is in points (not pixels).
You can do a conversion from axes data units (meters in this case) to the width of the axes in points, in order to set the MarkerSize appropriately. This will make the markers have a diameter of 10 microns:
w = 10; %e-6 Beam radius in µm
frep = 100e3; % kHz Pulse repetition frequency.
T = 1/frep; %1/s Timelapse between 2 Pulses
vscan = 1000e-3; %m/s Scan velocity
dP = vscan*T;%m Spacing between two Circles
slx = 0.0001; %m Scan length in x-axis.
NxL = int16(slx/dP); % Number of Circles in x-axis
xL = double((0:NxL))*dP; %m
dL = 100e-6; %m Linienabstand
NyL=10;
yL = (0:NyL)*dL; %m
hold on
ax = gca();
ax_units = get(ax,'Units');
set(ax,'Units','points');
ax_pos = get(ax,'Position')
ax_pos = 1×4
54.5527 34.6400 325.2182 256.6509
set(ax,'Units',ax_units);
h = zeros(1,NxL);
for ix = 1:NxL %Scan in x-Richtung
h(ix) = plot(xL(ix),yL(NyL/2),'ro');%,'Markersize',w)
end
xl = get(ax,'XLim');
w_pts = w*1e-6/(xl(2)-xl(1))*ax_pos(3)
w_pts = 32.5218
set(h,'MarkerSize',w_pts);
hold off
Of course whenever the width of the axes or the XLim change, you'd have to update the MarkerSize accordingly.
  8 Comments
Hussam Saddour
Hussam Saddour on 13 Mar 2022
i know that if i ask this it might be against community rules ,but what is the best way of learning all these commands, i'm actually a little bit lost where should i begin
Voss
Voss on 13 Mar 2022
I don't think it's against the rules to ask for help learning MATLAB - in fact, that's the purpose of MATLAB Answers.
I can only speak from my own experience learning MATLAB, but for me the best way to learn new MATLAB commands is to read the MATLAB documentation and try the commands out myself on the command line or in a simple script until they make sense to me. I might have to make several attempts, trying different things until I get it to do what I'm trying to do. It's all about experimentation and learning from what I've tried - seeing (and remembering) what works and what doesn't work.
In addition to experimentation/trial-and-error, there are structured courses you may be interested in:
Remember (to paraphrase a quote attributed to Niels Bohr): "An expert is someone who has made all the mistakes that can be made, in a very narrow field." So try things yourself, post a question here if you get stuck, and someone who has made the same mistake before will help you out.

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!