- figure: https://www.mathworks.com/help/matlab/ref/figure.html
- legend: https://www.mathworks.com/help/matlab/ref/legend.html
Make a scatter plot bigger and ad legend, axis
조회 수: 1 (최근 30일)
이전 댓글 표시
I have the following scatter plot, created from for loops. I want to make every staple as thick as possible, like so staple 1 and 2 are in contact with a contour seperating them. I also want a legend telling what the colors represent.. But I do not know how to make one
hold on
for y=1:2
xx=cell(length(AAG{y}),1);
I=cell(length(AAG{y}),1);
for o=1:length(AAG{y})
xx{o} =AAG{y}{o};
I{o}=AAI{y}(o);
end
for k1 = 1:length(AAG{y})
scatter(ones(1,numel(xx{k1}))*y, xx{k1},ones(1,numel(xx{k1}))*I{k1})
end
end
xlim([0 3])
hold off
댓글 수: 0
답변 (1개)
Abhishek Chakram
2023년 10월 11일
Hi Joel Schelander,
It is my understanding that you want to make the scatter plot bigger and add legend to it. To achieve this, you can resize the “figure” to have the desired height and width using “Position” parameter. For adding the legends, you can use “legend” function. Here is a sample code for the same:
% Generate random data
x1 = rand(1, 100);
y1 = rand(1, 100);
x2 = rand(1, 100);
y2 = rand(1, 100);
x3 = rand(1, 100);
y3 = rand (1, 100);
figure ('Position', [100, 100, 800, 600]);
% Adjust the width and height as needed
% 3rd parameter is the width of the figure
% 4th parameter is the height of the figure
hold on;
scatter(x1, y1, 50, 'red', 'filled');
scatter(x2, y2, 50, 'green', 'filled');
scatter(x3, y3, 50, 'blue', 'filled');
hold off;
xlabel('X');
ylabel('Y');
title('Scatter Plot with Different Colors');
% Add legend
legend('Array 1', 'Array 2', 'Array 3');
You can refer to the following documentation to know more about the functions used:
Best Regards,
Abhishek Chakram
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!