Effacer les filtres
Effacer les filtres

stem3- different stem color and marker color for different values in an axis.

10 vues (au cours des 30 derniers jours)
Hello all,
I have a following randomly generated stem3 plot. I wanted to know if there was any way we could assign different colors to markers corresponding different values in x-axis i,e x =1, 2,3,4 should have different colored markers?
untitled.jpg

Réponse acceptée

Star Strider
Star Strider le 10 Sep 2019
Two options:
x = (ones(50,1)*(1:4))'; % Create Data
y = ones(size(x,1),1)*(1:50); % Create Data
z = randi(99, size(x)); % Create Data
fc = jet(size(x,1)); % Choose Colormap
figure
hold all
for k = 1:size(x,1)
stem3(x(k,:), y(k,:), z(k,:), 'Color','b', 'MarkerFaceColor',fc(k,:))
end
hold off
grid on
view(-30,35)
figure
stem3(x(:), y(:), z(:))
hold on
scatter3(x(:), y(:), z(:), [], x(:), 'filled')
hold off
grid on
view(-30,35)
Experiment to get the result you want.
  2 commentaires
Vishakha Ramani
Vishakha Ramani le 10 Sep 2019
Works like a magic. Thank you very much.
Star Strider
Star Strider le 10 Sep 2019
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Stem Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by