adding contour lines to pcolor plot

Hi everyone,
I'm trying to add contour lines at 13 degrees to my pcolor plot, but I get the following error:
Error using contour
Input arguments must be numeric or objects which can be converted to double.
Here's my code:
t1 = datetime(2021, 5, 1)
t2 = datetime(2021, 9, 30)
dateVector = t1:t2
combinedaverages = [dailyaverages; dailyaverages06; dailyaverages07; dailyaverages08; dailyaverages09];
figure
pcolor(dateVector, depth, combinedaverages')
set(gca, 'YDir','reverse')
shading flat
ylim([0 70])
colorbar
hold on
contour(dateVector,depth,combinedaverages',[13 13],'k');
Variables in the code are:
combine averages: 153x33 double
depth: 33x1 single
dateVector: 1x153 datetime

4 件のコメント

Mathieu NOE
Mathieu NOE 2023 年 3 月 22 日
hello
it's good practice to share the data (as mat file) along the code (if you want someone to help you)
all the best
Giulia
Giulia 2023 年 3 月 22 日
Hi, the data are about 150 netcd files..how do I share it all?
Adam Danz
Adam Danz 2023 年 3 月 22 日
編集済み: Adam Danz 2023 年 3 月 22 日
The data are the variables you mentioned in your question. If you save them to a mat file and attach them we can run the code in your question.
Giulia
Giulia 2023 年 3 月 23 日
Hi Adam, thank you.
Here are my mat files:

サインインしてコメントする。

 採用された回答

Mathieu NOE
Mathieu NOE 2023 年 3 月 24 日

0 投票

hello again
maybe this ?
figure
pcolor(dateVector, depth, combinedaverages')
set(gca, 'YDir','reverse')
shading flat
ylim([0 70])
colorbar
hold on
contour(1:numel(dateVector),depth,combinedaverages','k');

4 件のコメント

Giulia
Giulia 2023 年 3 月 27 日
Hi Mathieu, thanks a lot for your response!
How do I apply the code to set contour lines at 10 and 20 m?
Mathieu NOE
Mathieu NOE 2023 年 3 月 27 日
hello Giulia
see code modification below
clc
figure
pcolor(dateVector, depth, combinedaverages')
set(gca, 'YDir','reverse')
shading flat
ylim([0 70])
colorbar
hold on
V = [10 20]; % set contour lines at 10 and 20 m
contour(1:numel(dateVector),depth,combinedaverages',V,'k');
but the contour line at 20 m will not show up as your Z data (combinedaverages) range spans from 9.0550 to 17.2330
Giulia
Giulia 2023 年 3 月 27 日
Great! Thank you so much again for your help!
All the best
Mathieu NOE
Mathieu NOE 2023 年 3 月 27 日
My pleasure !

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeContour Plots についてさらに検索

タグ

質問済み:

2023 年 3 月 21 日

コメント済み:

2023 年 3 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by