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

1 回表示 (過去 30 日間)
EMILIO BASTA 2021 年 3 月 5 日
回答済み: Adam Danz 2021 年 3 月 5 日
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

回答 (1 件)

Adam Danz
Adam Danz 2021 年 3 月 5 日
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.


Help Center および File ExchangeColormaps についてさらに検索


Community Treasure Hunt

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

Start Hunting!

Translated by