How do I plot a transparent contour and its colour?

4 ビュー (過去 30 日間)
Hamid Attar
Hamid Attar 2020 年 9 月 27 日
コメント済み: Alan Stevens 2020 年 9 月 27 日
Hello,
I have the following contour map with 3 zones from 3 sets of contour data, set to show just a single level, generated by the following code:
contourf(X,Y,ContourData1,[0.2,0.2],'LineWidth',2)
hold on
contourf(X,Y,ContourData2,[0.15,0.15],'LineWidth',2)
hold on
contourf(X,Y,ContourData3,[0.1,0.1],'LineWidth',2)
How do I make the coloured regions transparent, as well as change their colours? Currently the colours are default for the levels that each contour displays. I want something that looks like this:
Thanks

回答 (1 件)

Alan Stevens
Alan Stevens 2020 年 9 月 27 日
Possibly by assigning a handle like so:
h = contourf(X,Y,ContourData1,[0.2,0.2],'LineWidth',2);
then setting
h.CurrentObject.FaceAlpha = 0.2;
where you can replace 0.2 with a number between 0 and 1 until you get the degree of transparency you want.
I've not tested this on your figure as I don't have access to ContourData1, 2 and 3.
  2 件のコメント
Hamid Attar
Hamid Attar 2020 年 9 月 27 日
編集済み: Hamid Attar 2020 年 9 月 27 日
It doesn't work.
Please assume ContourData 1 2 3 are from the Peaks function, or some other readily available built-in matlab function for testing.
And what about the colours?
Alan Stevens
Alan Stevens 2020 年 9 月 27 日
Hmm. I used the patch function in my test. It looks like contourf doesn't have transparency control (other than on or off).

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

カテゴリ

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