フィルターのクリア

How to create a double scale of units in figures?

3 ビュー (過去 30 日間)
Giuseppe
Giuseppe 2022 年 4 月 23 日
コメント済み: Giuseppe 2022 年 4 月 23 日
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
figure
% Family of 50 planar Lyapunov orbits around L1
for k1 = 1:(numel(files_L1_L2_Ly_prop))
plot([Ly_orb_filt(1).prop(k1).orbits.x],[Ly_orb_filt(1).prop(k1).orbits.y],...
"Color",my_green*1.1,'LineWidth',0.3); hold on
end
axis equal; grid on; box on;
% Plot L1 point
plot(L_points_data(1).x,L_points_data(1).y,'.',...
'color',[0,0,0],'MarkerFaceColor',my_green,'MarkerSize',10);
text(L_points_data(1).x-0.00015,L_points_data(1).y-0.0008,'L_{1}');
% Family of 50 planar Lyapunov orbits around L2
for k2 = 1:(numel(files_L1_L2_Ly_prop))
plot([Ly_orb_filt(2).prop(k2).orbits.x],[Ly_orb_filt(2).prop(k2).orbits.y],...
"Color",my_orange*1.1,'LineWidth',0.3); hold on
end
% Plot L2 point
plot(L_points_data(2).x,L_points_data(2).y,'.',...
'color',[0 0 0],'MarkerFaceColor',[0 0 0],'MarkerSize',10);
text(L_points_data(2).x-0.00015,L_points_data(2).y-0.0008,...
'$L_{2}$','Interpreter',"latex"); hold on
% Plot Earth + Moon system
plot(AstroData.mu_SEM_sys -1,0,'.',...
'color',my_blue,'MarkerFaceColor',my_blue,'MarkerSize',20);
text(AstroData.mu_SEM_sys-1.00238,0-0.001,'$Earth + Moon$','Interpreter',"latex");
xlabel('$x$','interpreter','latex','fontsize',12);
ylabel('$y$','interpreter','latex','FontSize',12);

回答 (1 件)

DGM
DGM 2022 年 4 月 23 日
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 件のコメント
Giuseppe
Giuseppe 2022 年 4 月 23 日
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?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by