Scatter plot with variable symbol size - it's not linear
4 次查看(过去 30 天)
显示 更早的评论
I'm trying to use the feature in the scatter plot where the symbol size is proportional to a variable and it seems that the scaling of the symbol size is not linear.
Here is some test code and the resulting plot:
x = 1:100;
y = ones( size(x) );
scatter( x, y, 100*x, '|' );
xlim( [0 101] );
ylim( [0 2] );
Is this the expected behaviour? I need the symbol size to vary linearly with the variable.
0 个评论
采纳的回答
Jon
2023-8-4
编辑:Jon
2023-8-4
According to the documentation for scatter, the size in "points squared" units, try this
x = 1:100;
y = ones( size(x) );
scatter( x, y, x.^2,'|' );
xlim( [0 101] );
ylim( [0 2] );
2 个评论
Jon
2023-8-4
Your welcome. When first I read the documentation it wasn't really clear to me whether that meant I should take the square root of x, or square it. A little trial and error quickly showed squaring it was the right way to go.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!