필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrix Computations에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by