Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

1 visualización (últimos 30 días)
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

Respuestas (1)

Paul Wolfram
Paul Wolfram el 20 de Sept. de 2019
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

La pregunta está cerrada.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by