How can I plot a matrix using pcolor and colorscale as log?

조회 수: 7 (최근 30일)
AMIT SINGH CHANDEL
AMIT SINGH CHANDEL 2024년 7월 16일
답변: Sandeep Mishra 2024년 8월 8일
I have a timeseries matrix data of a lidar. I want to plot the time series keeping colorbar as logscale.
I have written the following code but it shows an error
load time_June.mat
load elevation_June_5km.mat
load backscatter_June_5km.mat
load raw_backscatter_June_5km.mat
figure(1);
pcolor(time_June, elevation_June_5km, backscatter_June_5km); shading interp
c = colorbar;
caxis([10^-7 10^-4]);
set(gca, 'ColorScale', 'log');
c.Label.String = 'Attenuated backscatter coefficient (m^{-1} sr^{-1})';
c.Ruler.Scale = 'log';
c.Ruler.MinorTick = 'on';
colormap jet;
set(gca, 'YDir', 'normal');
xlabel('Time (LT)');
ylabel('Altitude (km)');
axis tight;
set(gca, 'FontName', 'Times', 'FontSize', 14);
startDate = datetime(2023, 6, 16);
endDate = datetime(2023, 6, 25);
xlim([startDate, endDate]);
Error:
Warning: Error creating or updating Surface
Error in value of property CData
DataSpace or ColorSpace transform method failed.
  댓글 수: 2
Sahas
Sahas 2024년 7월 17일
이동: Star Strider 2024년 7월 17일
I've taken a look at the code and ran a few simlations with dummy data. But to generate the given errors, it would requires the specific files to load the workspace variables. Could you please share those files so that I could further investigate for the cause of this behaviour?

댓글을 달려면 로그인하십시오.

답변 (1개)

Sandeep Mishra
Sandeep Mishra 2024년 8월 8일
Hello AMIT SINGH CHANDEL,
I understand you are encountering an error while plotting the time series data with the 'ColorScale' property set to logscale.
Kindly follow the below workarounds to resolve the issue:
  • I observed that the ‘backscatter_June_5km.mat file contains some NaN values, which are causing the issue. To resolve the error, you can replace the NaN values in your 'backscatter_June_5km.mat' file with any double integer value. Refer to the below example code snippet which replacesNaN values with a fixed value 2.
% Replacing NaN values to a fixed value.
backscatter_June_5km = fillmissing(backscatter_June_5km, 'constant', 2);
  • It appears that MATLAB is handling the NaN values effectively after R2022a. Therefore, updating your MATLAB to R2022a or a later version might also resolve the issue.
I hope this will help you resolve the error and successfully plot the time series.

카테고리

Help CenterFile Exchange에서 Green에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by