- Logarithmic Scaling of MP: The MP array is transformed to a logarithmic scale to match the y-axis of the plot.
- Normalization and Scaling: The logMP variable is normalized and scaled back to the original range to ensure proper placement on the logarithmic y-axis.
Both Pcolor color plot and quiver plot in log scale
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hai,
I need to plot pcolor plot with y-axis in log scale and over plot with quiver plot in log scale.
Please help me how to do this.
Here is my code:
pcolor(1:365,pr(:,1),Ez1.*10^6);shading interp; colormap('jet(25)');colorbar;set(gca,'YScale','log');
hold on ; quiverInLogScale(1:15:365,MP,Zu1(:,1:15:365),Zv1(:,1:15:365))%,2,'-k')
set(gca,'Ydir','reverse');
caxis([0 8]);
ylim([1 100]);%xlim([0 396]);
title('(a) Daily mean (2005:2021) H2O (ppmv)')
set(gca, 'XTick', [1 31 59 90 120 151 181 212 243 273 304 335 365]);
set(gca,'XTickLabel', {'1' '31' '59' '90' '120' '151' '181' '212' '243' '273' '304' '335' '365'})
ylabel('P (hPa)')
set(gca, 'YTick', [1 10 21.54 31.62 56.23 100]);
set(gca,'YTickLabel', {'1', '10','21.54','31.62','56.23','100'})
colormap(ax1,jet(20)), colorbar
0 Kommentare
Antworten (1)
Abhinaya Kennedy
am 1 Aug. 2024
To plot a pcolor plot with a logarithmic y-axis and overlay it with a quiver plot also in a logarithmic scale, you need to ensure that both plots are consistent with the log scale.
% Data setup (assuming pr, Ez1, MP, Zu1, and Zv1 are already defined)
% pr should be a column vector representing the y-axis values
% Ez1 should be a matrix for the pcolor plot
% MP should be a column vector representing the y-axis values for the quiver plot
% Zu1 and Zv1 should be matrices for the quiver plot
% Create the pcolor plot
figure;
pcolor(1:365, pr(:, 1), Ez1 .* 10^6);
shading interp;
colormap('jet(25)');
colorbar;
set(gca, 'YScale', 'log');
hold on;
% Adjust MP to log scale for the quiver plot
logMP = log10(MP);
logMP = logMP - min(logMP); % Normalize to avoid negative values
logMP = logMP / max(logMP); % Scale to [0, 1]
logMP = 10 .^ (logMP * (log10(max(pr)) - log10(min(pr))) + log10(min(pr))); % Scale back to original range
% Create the quiver plot
quiver(1:15:365, logMP, Zu1(:, 1:15:365), Zv1(:, 1:15:365), 2, '-k');
% Set properties
set(gca, 'Ydir', 'reverse');
caxis([0 8]);
ylim([1 100]);
title('(a) Daily mean (2005:2021) H2O (ppmv)');
set(gca, 'XTick', [1 31 59 90 120 151 181 212 243 273 304 335 365]);
set(gca, 'XTickLabel', {'1', '31', '59', '90', '120', '151', '181', '212', '243', '273', '304', '335', '365'});
ylabel('P (hPa)');
set(gca, 'YTick', [1 10 21.54 31.62 56.23 100]);
set(gca, 'YTickLabel', {'1', '10', '21.54', '31.62', '56.23', '100'});
% Adjust colormap and colorbar
colormap('jet(20)');
colorbar;
This should give you a pcolor plot (https://www.mathworks.com/help/matlab/ref/pcolor.html) with a logarithmic y-axis and an overlaid quiver plot (https://www.mathworks.com/help/matlab/ref/quiver.html) that is consistent with the logarithmic scale.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Vector Fields 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!