matlab - How to associate the 'MarkerSize' to a value that means the radius of a plotted circle? -
i have 3 vectors of same length. 2 of them contain x
, y
coordinates of want plot. third 1 contains values want associate radius of plotted circle.
i have read 'markersize'
in plot
corresponds number of points in circumference, , if want use scatter
, third vector corresponds area of plotted circle.
nonetheless, want third vector associated radius
as such, how associate size of circles radius?
i have using plot
:
hold on; nd = 1 : 24 plot(xl(nd), -yl(nd), 'o', 'markerfacecolor', 'g', 'markeredgecolor', 'k', 'markersize', attribute(nd)) end
and using scatter
:
hold on; nd = 1 : 24 scatter(xl(nd), -yl(nd), attribute(nd), 'o', 'markerfacecolor', 'k', 'markeredgecolor', 'k') end
thanks in advance help.
assuming want use markersize
attribute plot
, said, number reports circumference of plotted marker in pixels.
well, know there's relationship between circumference of circle , radius:
source: math fun
therefore, circumference of circle equal pi
multiplied diameter, twice radius... so:
c = 2*pi*r
c
markersize
attribute. so, given radius, multiply 2*pi
desired circumference. bear in mind above computation yield floating point values, either take floor
, take ceil
or round
desired effect.
in other words, attribute
vector, assuming reporting radius:
attribute = floor(2*pi*attribute);
now use markersize
, plot
.
on other hand, if want use scatter
... know there's relationship between area of circle , radius:
source: wikihow
therefore, given radius, square radius , multiply pi
area, use third parameter scatter
... again, accounting floating-point precision:
attribute = floor(pi*attribute.^2);
you can use scatter
.
Comments
Post a Comment