How to create a double scale of units in figures?

2 views (last 30 days)
Hi guys,
I try to explain well my goal: I have a figure with several curves that are in dimensionless units (both x and y values).
I want to also show the SI units (km) both for x and y axis, as depicted in red in the figure above (I voluntalry omitted the numbers but their order of magnitude is about 1e+8 km). To get the km unit is sufficient to multiply the dimensionless value for 1.5e+8.
Here is my code and the matlab file "database.mat" that stores the database containing the curves.
load database.mat
% Family of 50 planar Lyapunov orbits around L1
for k1 = 1:(numel(files_L1_L2_Ly_prop))
"Color",my_green*1.1,'LineWidth',0.3); hold on
axis equal; grid on; box on;
% Plot L1 point
% Family of 50 planar Lyapunov orbits around L2
for k2 = 1:(numel(files_L1_L2_Ly_prop))
"Color",my_orange*1.1,'LineWidth',0.3); hold on
% Plot L2 point
'color',[0 0 0],'MarkerFaceColor',[0 0 0],'MarkerSize',10);
'$L_{2}$','Interpreter',"latex"); hold on
% Plot Earth + Moon system
plot(AstroData.mu_SEM_sys -1,0,'.',...
text(AstroData.mu_SEM_sys-1.00238,0-0.001,'$Earth + Moon$','Interpreter',"latex");

Answers (1)

DGM on 23 Apr 2022
Since R2019b, you should be able to use a method similar to this example to create the secondary x and y axes:
You may need to manipulate the limits, and ticks of the new axes in order to get them to correspond appropriately to the primary axes.
  1 Comment
Giuseppe on 23 Apr 2022
Thanks for you answer. I've already saw this method but in this way I would get overlapped curves, so it would be a waste of coding. Isnt' exist an easier solution to duplicate the axes and then change the scale?

Sign in to comment.


Find more on Matrix Computations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by