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

10 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Chunru
Chunru il 3 Ott 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')

Più risposte (1)

George Abrahams
George Abrahams il 14 Dic 2023
Modificato: George Abrahams il 20 Mar 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] )

Categorie

Scopri di più su Visual Exploration in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by