Colorbarのエラーについて

11 vues (au cours des 30 derniers jours)
ryu
ryu le 11 Avr 2023
Commenté : ryu le 13 Avr 2023
R2020aで以下のコードを実行したところエラーが出ました。
Z1 = peaks;
Z2 = membrane;
tiledlayout(2,1);
nexttile
contourf(Z1)
nexttile
contourf(Z2)
cb = colorbar;
cb.Layout.Tile = 'east';
(tiledlayoutページのコピペ、URL:https://jp.mathworks.com/help/matlab/ref/tiledlayout.html)
エラー文は
クラス 'matlab.graphics.illustration.ColorBar' のメソッド、プロパティまたはフィールド 'Layout' が認識されません。
エラー: untitled (line 9)
cb.Layout.Tile = 'east';
でした。
Layoutのが認識されない理由が全くわからず質問させていただきました。
回答いただければ幸いです。

Réponse acceptée

Kojiro Saito
Kojiro Saito le 11 Avr 2023
ドキュメントの例は最新版(現時点ではR2023a)のバージョンのものになっており、過去のバージョンのドキュメントは下記のようにhttps://jp.mathworks.com/help/releases/R2020a/matlab/ref/tiledlayout.html
のように「help」の後に「release/バージョン」を入れたURLでアクセスするか、日本語ドキュメントアーカイブのリンクから表示されます。
cb.Layout.Tile = 'east';」のところでエラーになってしまうのは、colorbar関数のlocationlayoutを設定できるのがR2021a以降で、R2020aでは対応していないためです。
対応するドキュメントを添付します。
→layoutの値は設定できません。
→layoutの値を設定できます。
  3 commentaires
Kojiro Saito
Kojiro Saito le 12 Avr 2023
R2020aでは共有のカラーバーを置く設定が無いので、locationを手動にして位置を指定することで実現できます。
cb = colorbar('Location', 'manual', 'Position', [0.92 0.11 0.025 0.8]);
Positionの4要素は[左からの位置, 下からの位置, 幅, 高さ] なので、好みに応じて修正してください。
ryu
ryu le 13 Avr 2023
tiledlayoutでは実装できなかったのでsubplotで実装しなおすとうまくいきました。
何度もご丁寧に説明してくださってありがとうございました。

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur カラーマップ dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!