Mutiple colorbars for mutiple scatter plots in the same figure
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to make two pairs of scatter plots, for a total of four. Where each pair will be shown by a different color bar. I looked for help on the Internet, but I couldn't find the best way to get the results I need. The other pair of plots is not shown in my figure.That means there should one more pair of scatter plots whoch are symmetric to the plots shown and will represent the second colorbar. Below is my code
x1 = rand(1,150); x2 = rand(1,100); y1 = x1.^2; y2 = x2.^(1/2);
x3 = rand(1,150); x4 = rand(1,100); y3 = -x3.^2; y4 = -x4.^(1/2);
Conc = [y1 y2]; Conc2 = [y3 y4];
figure
ax1 = axes;
scatter([x1, x2],[y1, y2],40,Conc,'filled');
axis equal
hold on
ax2 = axes;
scatter([x3, x4],[y3, y4],40,Conc2,'filled');
axis equal
hLink = linkprop([ax1,ax2],{'XLim','YLim','CameraUpVector','CameraPosition','CameraTarget'});
ax2.Visible = 'off';
ax2.XTick = []; ax2.YTick = [];
colormap(ax1)
colormap(ax2,'spring')
cb1 = colorbar(ax1,'Position',[0.1 0.1 0.05 0.815]);
cb2 = colorbar(ax2,'Position',[0.81 0.1 0.05 0.815]);
cb1.Label.String = 'Colorba1'; cb2.Label.String = 'Coloebar2';
cb1.Label.FontSize = 28; cb2.Label.FontSize = 28;
It will be a great help if anyone can put me in the right direction
0 Kommentare
Antworten (1)
Bjorn Gustavsson
am 6 Jun. 2022
Have a look at the file exchange contribution newcolorbar-multiple-colormaps-in-the-same-axes. It seems as it should let you do this.
HTH
1 Kommentar
Siehe auch
Kategorien
Mehr zu Colormaps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!