Borrar filtros
Borrar filtros

What is the best way to plot many curves as a parameter changes?

2 visualizaciones (últimos 30 días)
Giuseppe el 31 de Mzo. de 2022
Editada: Giuseppe el 4 de Abr. de 2022
Hi to everyone,
In my plot I have 50 curves and each of one corresponds to a specific value of a parameter called Jacobi constant. I want to show with an arrow and/or with a color gradient (and the relative legend in the colorbar form) the increasing direction of this constant in my figure, something like the following image modified "by hand":
Can you show me how to code the two alternatives (arrows and color gradient)?
For the color gradient plot I would want to color my curves according the colorbar colors shown in the right side of this image. Can you help me to code in order to satisfy my request?
Edit - The curves represent a family of Lyapunov orbits and each of them corresponds to a specific value of Jacobi constant. I attached the code and the relative data:
% Definition of path names
input_path_Fortran = 'D:\OneDrive\MSc_Thesis\Projects\Planar_Lyapunov_orbits\InputFiles\';
output_path_Fortran = 'D:\OneDrive\MSc_Thesis\Projects\Planar_Lyapunov_orbits\OutputFiles\';
%Automatic .txt file detection in the aboved specified folders
files_Ly_i_c = dir([input_path_Fortran, '\*.txt']);
files_Ly_filt_i_c = dir([output_path_Fortran, '\*.txt']);
% ESTERNO!!!!!!!!!!!!!!!!!!!!!!!!!!!!
% Import L-points coordinates (same file in SEM_L1 and SEM_L2 folders)
Ly_orb_filt_sys_data = table2struct(import_Ly_orb_sys_data_file(fullfile('SEM_L1','SEM_L1_SystemData.txt'),2,inf));
% Data structures creation
%Ly_orb_test = zeros(1,2) % Pre-allocations
for i=1:numel(files_Ly_i_c) % index for L1 and L2 (1:2)
% Import original databases for L1 and L2 Ly. orb. initial conditions respectively containing data about 4183 and 2171 orbits
Ly_orb(i).i_c = table2struct(import_Ly_orb_i_c_file(fullfile(input_path_Fortran,files_Ly_i_c(i).name),3,inf));
% Import filtered databases for L1 and L2 Ly. orb. initial conditions both containing data about 50 Ly orbits quasi-evenly spaced according Jacobi constant
Ly_orb_filt(i).i_c = table2struct(import_Ly_orb_i_c_file(fullfile(output_path_Fortran,files_Ly_filt_i_c(i).name),4,inf));
%Automatic detection of files of propagated L1 and L2 Ly. orb. in the relative folders
files_L1_L2_Ly_prop = dir(['SEM_L', num2str(i) '\*.txt']);
% Import propagated L1 and L2 Lyapunov orbits
for j = 1 : (numel(files_L1_L2_Ly_prop)-2) % Index for number of L1 and L2 orbits (1:50)
Ly_orb_filt(i).prop(j).orbits = table2struct(import_Ly_orb_prop_file(fullfile(['SEM_L', num2str(i)],files_L1_L2_Ly_prop(j).name),3,inf));
  2 comentarios
Riccardo Scorretti
Riccardo Scorretti el 1 de Abr. de 2022
Hi Giuseppe, can you send the data? Under which format do you have the curves?

Iniciar sesión para comentar.

Respuestas (1)

Sam Chak
Sam Chak el 1 de Abr. de 2022
I think @Giuseppe is trying to plot the potential energy around one of the 5 Lagrangian Points in the Earth–Moon System. I don't have his data, but if you are interested, you can try exploring the script below to adjust the color gradient. I'm not good at the plot properties. Can also refer to the contour image with color gradient in the link.
Desired_mesh = 61;
Lower_bound = -pi/2;
Upper_bound = pi/2;
step = (Upper_bound - Lower_bound)/(Desired_mesh - 1);
[x, y] = meshgrid(Lower_bound:step:Upper_bound, Lower_bound:step:Upper_bound);
mu = 0.01;
u = - (1 - mu)./sqrt((x + mu).^2 + y.^2) - mu./sqrt(abs(x - (1 - mu)).^2 + y.^2) - (1/2)*(x.^2 + y.^2);
contour(x, y, u, 5001)
  1 comentario
Giuseppe el 2 de Abr. de 2022
Editada: Giuseppe el 3 de Abr. de 2022
Thank you @Sam Chak, but I want to use different colors or a gradient color for my curves and then to show in a lateral colorbar the corresponding Jacobi constant as reported in the last example image of my question. Can you help me, please?

Iniciar sesión para comentar.


Más información sobre Red en Help Center y File Exchange.




Community Treasure Hunt

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

Start Hunting!

Translated by