Adding XYZ axis in RGB colors in the corner of a plot

12 ビュー (過去 30 日間)
Askic V
Askic V 2022 年 10 月 3 日
編集済み: George Abrahams 2024 年 3 月 20 日
Hello,
Is there any way I can add XYZ coordinate frame in a corner of a plot in Matlab? I have seen many times, reference coordinate frame is shown in the corner. I would like to use RGB colors to represent X Y and Z axis. The attached picture shown what I would like to have in the corner. Thanks

採用された回答

Chunru
Chunru 2022 年 10 月 3 日
plot(rand(10,1))
annotation('arrow', [0.8, 0.7], [0.8, 0.75], 'Color', 'r')
annotation('textbox', [0.68, 0.70 0.05 0.05], 'String', 'x', 'Color', 'r', 'EdgeColor', 'none')
annotation('arrow', [0.8, 0.9], [0.8, 0.75], 'Color', 'g')
annotation('textbox', [0.9, 0.75 0.05 0.05], 'String', 'y', 'Color', 'g', 'EdgeColor', 'none')
annotation('arrow', [0.8, 0.8], [0.8, 0.9], 'Color', 'b')
annotation('textbox', [0.8, 0.9 0.05 0.05], 'String', 'z', 'Color', 'b', 'EdgeColor', 'none')

その他の回答 (1 件)

George Abrahams
George Abrahams 2023 年 12 月 14 日
編集済み: George Abrahams 2024 年 3 月 20 日
Heres what I think is a pretty nice solution. The coordinate system bases (arrows) are plotted with my plotframe function on File Exchange.
% The main axes containing the object or data of interest.
axObj = axes;
[ X, Y, Z ] = peaks( 25 );
mesh( axObj, X, Y, Z ./ 3 )
% The small, corner axes containing the coordinate system plot.
axIcon = axes( Position=[0.75 0.75 0.2 0.2] );
plotframe( Parent=axIcon, LabelBasis=true )
% Synchronise the axes cameras.
linkprop( [axObj axIcon], [ "View", "CameraUpVector" ] );
% Some beautification.
set( gcf, Color=axObj.Color )
set( axIcon, CameraViewAngleMode="manual", ...
Color="none", XColor="none", YColor="none", ZColor="none" )
set( [axObj axIcon], DataAspectRatio=[1 1 1], PlotBoxAspectRatio=[1 1 1], View=[50 30] )

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by