How to make the marker size in a scatter plot 'to scale' with the axes?

45 ビュー (過去 30 日間)
AS
AS 2016 年 12 月 28 日
回答済み: Will Reeves 2022 年 3 月 14 日
I am using 3D scatter command using the following syntax: scatter3(X,Y,Z,S). The marker size is variable in my case where S is a vector. But the marker size is not in scale with the plot axes. How to make the marker size proportional to the axes units?
  1 件のコメント
Ahmet Cecen
Ahmet Cecen 2016 年 12 月 28 日
Can you take a screenshot with something like snipping tool and use annotation (as simple as paint or powerpoint) to show what you currently have and what you want to see?

サインインしてコメントする。

回答 (3 件)

Walter Roberson
Walter Roberson 2016 年 12 月 29 日
"The units for the marker area is points squared."
That is the same "points" as specifying 'points' for axes Units property
If you want to make something proportional, then
ax = gca;
old_units = get(ax, 'Units');
set(ax, 'Units', 'points');
pos_points = get(ax, 'Position');
set(ax, 'Units', old_units);
narrower_part_points = min(pos_points(3:4));
Now create something proportional to narrower_part_points. But remember that the size for scatter()'s purpose is area, which is points square. So for example something rand with diameter 1/20th of the width should be expressed as pi * narrower_part_points.^2 / 4
the division by 4 is the change between pi*r^2 and pi*(d/2)^2

KSSV
KSSV 2016 年 12 月 29 日
x = rand(10,1) ; % some random x
y = rand(10,1) ; % some random y
sizes = randsample(1:100,10) ; % random sizes for 1o points, which lie between 1 to 100
scatter(x,y,sizes,sizes,'filled') ; % scatter plot with varying sizes and sizes as color on them
You can extend it to 3D case.
  2 件のコメント
AS
AS 2016 年 12 月 29 日
Sizes are different for markers but the size is not in the same scale as that of the axes.
KSSV
KSSV 2016 年 12 月 29 日
you fix the sizes depending on your scale.

サインインしてコメントする。


Will Reeves
Will Reeves 2022 年 3 月 14 日
I'd like this functionality too, but I would like the simplicity of being able to pick an "absolute size" drawn in one (or more) of the axis units. For instance I currently use the "viscircles" function, found in the image processing tool box, to achieve this. However, it's really really slow if you want to visualise thousands of cirlces of say 20 micron radius on a plot. It also doesn't offer the "filled" functionality of the scatter plot.

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by