overtop IMAGESC text and change colorbar colors in white for some value of the text

4 views (last 30 days)
Hi guys!
This is how I get this graph, which shows the power values through the colormap , and on the same grid it overtop a text which represents the probability occurance , which is simply a matrix transormed in a character vector and overtop to the same graph.
% Grid
% Plot grid
title('Wave power chart [kW]', 'FontSize',18);
xlabel('Hs [m]');ylabel('Tp [s]');
grid on;
set(gca,'xtick', linspace(Hs_x(1)-0.25,Hs_x(end)+0.25,length(Hs_x)+1),'ytick', linspace(Tp_y(1)-0.5,Tp_y(end)+0.5,length(Tp_y)+1));
set(gca,'xgrid', 'on', 'ygrid', 'on', 'gridlinestyle', '-', 'xcolor', 'k', 'ycolor', 'k');
a.Ticks = [0 0.1 50:100:850]
hColourbar.Label.Position(1) = 3
I would like to create white squares when the probability 'f' i equal to 0%. It means that in every square, where the value of probability matrix is equal to 0% , the square of the plot must be white. Any clue?
PLS, help
thank you

Answers (1)

Adam Danz
Adam Danz on 5 Mar 2021
The 0.0% values are rounded to 1dp so any values between -0.049 and 0.049 will show 0.0%. So, you need to find the indices of f that are within that range and then set the corresponding values in Pw to NaN. Then set the first value of your colormap to white using ax.Colormap(1,:)=[1,1,1];where ax is the axis handle.

Community Treasure Hunt

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

Start Hunting!

Translated by