フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Looped subplot with different marker face colors for each data point within each subplot

1 回表示 (過去 30 日間)
Paul Wolfram
Paul Wolfram 2019 年 9 月 20 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi collective brain,
I am trying to create 24 subplots where colors differ for each data point within each subplot, but are repeated in each subplot. Please see both a screenshot and my code below (working example). As you can see in each subplot all markers are green, although I would like them to be red, green, blue, red, green, blue, red, green (as indicated in vector scatter_clr). How do I fix this? If someone could also help me understand how I can use color triplets, .e.g [1 0 1], instead of characters that would be of great help too.
Thanks in advance for any hints!
x_data = rand(8,24);
y_data = rand(8,24);
scatter_clr = ['r';'g';'b';'r';'g';'b';'r';'g'];
scatter_clr = repmat(scatter_clr,1,24);
figure
for j = 1:8;
for k = 1:24;
subplot(6,4,k)
scatter1 = scatter(x_data(:,k)/1000, y_data(:,k)/1000, [], scatter_clr(j,k),'filled');
end
end

回答 (1 件)

Paul Wolfram
Paul Wolfram 2019 年 9 月 20 日
Think I just figured the first part out, see below. Still wondering how to use triplets. Thanks
example_scatter_plot2.JPG
clc
clear
close all
x_data = rand(8,24);
y_data = rand(8,24);
scatter_clr = {'r';'g';'b';'r';'g';'b';'r';'b'};
scatter_clr = repmat(scatter_clr,1,24);
figure
for j = 1:8;
for k = 1:24;
subplot(6,4,k)
scatter1(j) = scatter(x_data(j,k), y_data(j,k), [], scatter_clr{j,k},'filled');
hold on
end
end

この質問は閉じられています。

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by