How do I label the scatter colorbar with month and day
22 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I wanted to color my scatter plot by date. I was able to do that with the code below but I want to me able to discrimate between dates better than just the month labels. Can I force the colorbar labels to be Month and Date? The code I am using does this fine if I plot the scatter plots by themselves but not as part of another figure. (maybe it is a size issue). This is how I am plotting now (see figures attached):
ax(3) = subplot(2,2,4)
% plot(b_range(k1+3:k2),Bmean3637(k1:k2-3),'.','color','k','markersize',15)
scatter(b_range(k1+3:k2),Bmean3637(k1:k2-3),[],btimestamp(k1+3:k2),'filled')
set(gca,'fontsize',16)
xlabel('Daily pH Range (1 mab)')
ylabel('BEUTI (3-day lag)')
colormap(jet);
h = colorbar; datetick(h,'y','keeplimits');
0 commentaires
Réponses (1)
Divija Aleti
le 27 Août 2020
I understand that you want to label the colorbar with month and day, even if it is plotted as a subplot.
Generally, when the size of a figure changes, labels get squeezed as an expected behaviour. Kindly have a look at this possible workaround/solution.
b_range = (8.1-7.75)*rand(82,1)+7.75;
Bmean3637 = 25*rand(82,1)-5;
c=linspace(1,10,82);
ax(3) = subplot(2,2,4);
scatter(b_range,Bmean3637,[],c,'filled')
set(gca,'fontsize',16)
xlabel('Daily pH Range (1 mab)')
ylabel('BEUTI (3-day lag)')
colormap(jet);
labels = {'07/08','07/15','07/22','07/29','08/05','08/12','08/19','08/26','09/02','09/09','09/16','09/23','09/30','10/07'}; %explicitly indicate the labels
h = colorbar('Ticks',1:14,'TickLabels',labels,'limits',[1 14]);
0 commentaires
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!