Colorbarのエラーについて
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ryu
el 11 de Abr. de 2023
Comentada: ryu
el 13 de Abr. de 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のが認識されない理由が全くわからず質問させていただきました。
回答いただければ幸いです。
0 comentarios
Respuesta aceptada
Kojiro Saito
el 11 de Abr. de 2023
ドキュメントの例は最新版(現時点ではR2023a)のバージョンのものになっており、過去のバージョンのドキュメントは下記のようにhttps://jp.mathworks.com/help/releases/R2020a/matlab/ref/tiledlayout.html
「cb.Layout.Tile = 'east';」のところでエラーになってしまうのは、colorbar関数のlocationにlayoutを設定できるのがR2021a以降で、R2020aでは対応していないためです。
対応するドキュメントを添付します。
→layoutの値は設定できません。
→layoutの値を設定できます。
3 comentarios
Kojiro Saito
el 12 de Abr. de 2023
R2020aでは共有のカラーバーを置く設定が無いので、locationを手動にして位置を指定することで実現できます。
cb = colorbar('Location', 'manual', 'Position', [0.92 0.11 0.025 0.8]);
Positionの4要素は[左からの位置, 下からの位置, 幅, 高さ] なので、好みに応じて修正してください。
Más respuestas (0)
Ver también
Categorías
Más información sobre Subplots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!