フィルターのクリア

Plot data above current axis

6 ビュー (過去 30 日間)
Anas Khan
Anas Khan 2022 年 12 月 1 日
コメント済み: Anas Khan 2022 年 12 月 2 日
I have a pseudocolor (contourf) plot that I want to add to in the margins around the plot. How do I place the plot the new data (just some lines) in the location shown in the circleed area in picture attached?

採用された回答

Walter Roberson
Walter Roberson 2022 年 12 月 2 日
There are several possible ways to proceed:
  • Create two different axes() specifying Position for each one, possibly using 'Units', 'normalized'. Use the same width and same xlim() for both of them -- consider using linkaxes . If you use this option, you can use whatever y coordinate range is easiest for each axes; OR
  • use subplot or tiledlayout to create subplots. It is easier to control spacing with tiledlayout -- but you still might not be able to get them as close as you would like. If you use this option, you can use whatever y coordiante range is easiest for each axes; OR
  • image() and imagesc() and pcolor() and contourf() by default use the matrix sizes to establish coordinates. You can take the y coordinates of the additional plot and scale them to have range proportionate to the array sizes, and then add the coordinate of the top of the array to all of the y values and then plot using that -- effectively using the same axes but positioning the data above the color area. This has the advantage of only using one axes, but has the disadvantage that axes labels and datatips will not match the actual y range unless you do a bunch of playing around.
  • you could use yyaxis left and yyaxis right, but in order to position the other plot above the color area you need to do a bunch of playing with coordinate scales and ylim
  3 件のコメント
Walter Roberson
Walter Roberson 2022 年 12 月 2 日
img = imread('cameraman.tif');
numrow = size(img,1);
marginy = numrow + double(max(img,[],1))/15;
ax = gca;
contourf(ax, img);
hold(ax, 'on');
plot(ax, marginy, 'r-');
hold(ax, 'off');
ylim(ax, [0 numrow]);
ax.Clipping = false;
Anas Khan
Anas Khan 2022 年 12 月 2 日
Thanks!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by