How do I label the scatter colorbar with month and day

22 views (last 30 days)
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');

Answers (1)

Divija Aleti
Divija Aleti on 27 Aug 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]);

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!