フィルターのクリア

Shaded Contour and Line Contour in one CONTOURF

10 ビュー (過去 30 日間)
Bhowmik.U
Bhowmik.U 2018 年 8 月 4 日
編集済み: jonas 2018 年 8 月 20 日
I have a matrix A=m x n; X=m x 1; Y=n x 1; contourf(X,Y,A','linestyle','none')
I wish to superpose another matrix B (m*n) "in LINE CONTOUR" onto the previous
Please help...
It would be great if I knew to plot matrix B both in single color line with values written in between, or a contour with different color scheme....
  2 件のコメント
jonas
jonas 2018 年 8 月 4 日
I don't understand what you mean, what is a line contour? One without faces, like the normal contour?
Bhowmik.U
Bhowmik.U 2018 年 8 月 5 日
Please find the enclosed image as an example image I just downloaded from Internet to make my problem clear
Here the color is my Matrix : A (in shaded form) and by line contour, I mean the black lines within it, with lables in number.. (my Matrix B)
...Hope I am clear now

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

採用された回答

jonas
jonas 2018 年 8 月 5 日
編集済み: jonas 2018 年 8 月 5 日
Yea that's fairly easy. An example:
A=peaks(100);
B=peaks(75);
[~,h1]=contourf(A,'linestyle','none');hold on
[c,h2]=contour(B,'linecolor',[0 0 0])
set(h2,'ContourZLevel',10)
clabel(c,h2)
The second to last row makes sure that h2 is always drawn on top, although this case its not needed.
  7 件のコメント
Bhowmik.U
Bhowmik.U 2018 年 8 月 20 日
because when I try inserting colorbar after
%colorbar(ax1)
the colorbar enters the plot area producing mess.. :(
jonas
jonas 2018 年 8 月 20 日
編集済み: jonas 2018 年 8 月 20 日
Happy to help.
The problem is that the colorbar changes the position-property of one axes when you place it outside of the plot area, as it is set to location='eastoutside' by default. There are several ways to solve this:
1) Align the position of the two axes at the end of the script. Add this at the end of the script:
cb=colorbar(ax1)
ax1pos=get(ax1,'position')
set(ax2,'position',ax1pos)
2) add colorbar inside the plot and then move it outside by changing its position. This prevents the axes position from being changed at all. Add this at the end of the script:
cb=colorbar(ax1,'location','west')
cb.Position=cb.Position+[0.6 0 0 0];
3) add colorbar normally, i.e. outside of plot, and change the position of the axes back again afterwards
ax1pos=get(ax1,'position')
cb=colorbar(ax1)
set(ax1,'position',ax1pos)

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by