
customize size each dot in a scatter plot
조회 수: 23 (최근 30일)
이전 댓글 표시
Hello!
Lets start... I have an array of data, to simplify, only two columns, X and Y.
I did some previous calculation in teh array, and I only want to plot some positions of the array.
The positions to be plotted are stored in a vector.
To plot the points I just using
plot(Array_specs(index,1),Array_specs(index,2))
so far so good... now, for each x,y I would like to assign different weight by making the dot bigger.
I know this is done with LineWidth.. but linewidth do not accept a vector as an input.. this means that I need to manually plot each point in the scatter plot,
plot(Array_specs(index(i),1),Array_specs(index(i),2), 'LineWidth', number(index(i)) )
the problem is that the function takes really long time, as obviusly it is not optimized. Is any optimum way to do that?
How can assign a different linewidth to each of my XY points without manually check the array?
Best Regards,
Miguel
댓글 수: 0
채택된 답변
Image Analyst
2020년 1월 30일
Try using scatter. With scatter() can specify sizes and colors for each element in your (x,y) pairs.
numPoints = 300;
x = rand(1, numPoints) - 0.5;
y = rand(size(x)) - 0.5;
% Sizes = distance from origin
sizes = 200 * sqrt(x.^2 + y.^ 2);
% Colors according to the jet colormap and distance from origin.
indexes = round(rescale(sizes, 1, numPoints));
colors = jet(numPoints); % Initialize
colors = colors(indexes,:); % Colored according to distance.
% Do the plot
scatter(x, y, sizes, colors, 'filled');
grid on;

댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
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!