
Assign a specific Value to Marker Size in relation with axes
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hussam Saddour
am 27 Feb. 2022
Kommentiert: Voss
am 13 Mär. 2022
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 Kommentare
Simon Chan
am 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

Akzeptierte Antwort
Voss
am 27 Feb. 2022
Bearbeitet: Voss
am 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')
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)
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 Kommentare
Voss
am 13 Mär. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



