I have three vectors of the same length. Two of them contain the X
and Y
coordinates of what I want to plot. The third one contains values that I want to associate the radius of the plotted circle.
I have read that 'MarkerSize'
in plot
corresponds the number of points in the circumference, and if I want to use scatter
, the third vector corresponds to the area of the plotted circle.
Nonetheless, I want my third vector to be associated with the radius
As such, how to associate the size of the circles with the radius?
I have this using plot
:
hold on;
for nd = 1 : 24
plot(xL(nd), -yL(nd), 'o', 'MarkerFaceColor', 'g', 'MarkerEdgeColor', 'k', 'MarkerSize', attribute(nd))
end
And this using scatter
:
hold on;
for nd = 1 : 24
scatter(xL(nd), -yL(nd), attribute(nd), 'o', 'MarkerFaceColor', 'k', 'MarkerEdgeColor', 'k')
end
Thanks in advance for this help.
Assuming you want to use
MarkerSize
as the attribute forplot
, as you said, this number reports the circumference of the plotted marker in pixels.Well, you know there's a relationship between the circumference of a circle and its radius:
Source: Math Is Fun
Therefore, the circumference of a circle is equal to
pi
multiplied by the diameter, which is twice the radius... so:C
would be theMarkerSize
attribute. So, given a radius, simply multiply by2*pi
to get the desired circumference. Bear in mind that the above computation will yield floating point values, so either take thefloor
, take theceil
orround
to get the desired effect.In other words, do this to your
attribute
vector, assuming you are reporting the radius:Now use this with
MarkerSize
andplot
.On the other hand, if you want to use
scatter
... well you know there's a relationship between the area of a circle and its radius:(source: whstatic.com)
Source: WikiHow
Therefore, given the radius, simply square the radius and multiply by
pi
to get the area, then use this as the third parameter toscatter
... again, accounting for floating-point precision:You can now use this with
scatter
.