Linking 2D datapoint colors to colormap
Afficher commentaires plus anciens
I am trying to make the color of my swarm chart's data points correspond to the colormap/colorbar. I've tried functions such as imagesc(), colormap(), or just plain old color(), but none of these seem to be working.
Here are the arrays I'm working with, stored as doubles:
data1 =
0.330000000000000
0.500000000000000
0.570000000000000
0.450000000000000
0.460000000000000
0.700000000000000
0.600000000000000
-0.0900000000000000
0.400000000000000
-0.340000000000000
-0.360000000000000
-0.750000000000000
-0.0300000000000000
-0.100000000000000
grp1 =
2
2
2
2
2
2
2
2
2
3
3
3
3
3
Here is my code so far:
figure; swarmchart(grp1(1:14,1)-1, data1(1:14,1), 30, c, 'filled')
figure; swarmchart(grp1(1:14,1)-1, data1(1:14,1), 30, c, 'filled')
hold on; boxplot( data1(1:13,1),grp1(1:13,1))
hold on; plot([1.:1:3.5]-1,[0 0.45 -0.35])
hold on; plot([0 3], [0 0], '--')
c = colormap(turbo)
colorbar
clim([-0.8 0.8])
xlim([0 3])
title('Network Activity vs. Disease Progression')
xlabel('Pathological Burden')
ylabel('Electrophysiological Disturbance')
xticklabels({'Low Burden', 'High Burden'})
Using c in the swarmplot calls throws this error message:

If I comment out c, here is my output:

I've found people doing this in older MATLAB versions and their explanations are not so helpful for me, unfortunately. Would anyone be able to send an idea/solution for this? I would sincerely appreciate your effort.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

