- 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!