Filter löschen
Filter löschen

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

15 Ansichten (letzte 30 Tage)
Askic V
Askic V am 3 Okt. 2022
Bearbeitet: George Abrahams am 20 Mär. 2024
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

Akzeptierte Antwort

Chunru
Chunru am 3 Okt. 2022
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')

Weitere Antworten (1)

George Abrahams
George Abrahams am 14 Dez. 2023
Bearbeitet: George Abrahams am 20 Mär. 2024
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] )

Kategorien

Mehr zu Visual Exploration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by