How to manage colormap and colorbar in a matlab multi-curves plot?
Mostra commenti meno recenti
Hi to everyone,
I have a plot with 50 curves that are the orbits of 50 periodic orbits, each orbit correspond to a value of a constant called "Jacobi constant" (it is an energy value) , so I have a vector of 50 elements called "jacobi_cst" that stores the followings 50 scalars:
3.000576748353570
3.000583342259840
3.000590018845460
3.000596554947660
3.000603171772120
3.000609870077710
3.000616425935580
3.000623060310100
3.000629657944820
3.000636330415510
3.000642857256680
3.000649560630930
3.000656116141060
3.000662738391370
3.000669315388860
3.000675958537960
3.000682547292110
3.000689196186970
3.000695791284050
3.000702431180730
3.000709016645110
3.000715644446600
3.000722309400740
3.000728906460450
3.000735532899990
3.000742084743060
3.000748750854930
3.000755335851910
3.000761928862980
3.000768609354090
3.000775192199620
3.000781845363950
3.000788475204760
3.000795067776960
3.000801695858850
3.000808265737810
3.000814922863360
3.000821489088600
3.000828099771820
3.000834723697250
3.000841330136040
3.000847948043080
3.000854592397690
3.000861196034850
3.000867791975870
3.000874419173230
3.000881028967010
3.000887643313580
3.000894276927840
3.000900891023230
So we have that to each orbit is associated one of these scalar (in increasing order). Can you show me how to color each orbit by using the "colormap" command and then how to show the colors in a lateral bar by using the command "colorbar"? Can you also indicate as display an accetable number of the scalars (surely, the first one and the last one and for example 10 values in total, by using at least 6 decimal digits) on the lateral colorbar?
Here is the code fragment that I use to plot orbits:
fig = figure;
for k1 = 1:50
plot([Ly_orb_filt(1).prop(k1).orbits.x],[Ly_orb_filt(1).prop(k1).orbits.y],...
"Color",my_green); hold on
end
% Info about number of Lyapunov orbits
dim = [.168 .85 .275 .06];
str = '$50 Planar\ Lyapunov\ orbits\ $';
annotation('textbox',dim,'String',str,'Interpreter',"latex",'FitBoxToText','off',...
'BackgroundColor',[1 1 1],'FontSize',9);
% Plot L1 point
plot(Ly_orb_filt_sys_data(1).x,Ly_orb_filt_sys_data(1).y,'.',...
'color',[0,0,0],'MarkerFaceColor',my_green,'MarkerSize',10);
text(Ly_orb_filt_sys_data(1).x-0.00015,Ly_orb_filt_sys_data(1).y-0.0008,'L_{1}');
%Primary bodies plots
plot(AstroData.mu_SEM_sys -1,0,'.',...
'color',my_blue,'MarkerFaceColor',my_blue,'MarkerSize',20);
text(AstroData.mu_SEM_sys-1.0028,0-0.001,'$Earth + Moon$','Interpreter',"latex","FontSize",9);
grid on; hold off
xlabel('$x$','interpreter','latex','fontsize',12);
ylabel('$y$','interpreter','latex','FontSize',12);
Sorry if my example is not reproducible but I avoid to load many data files and code lines.
To reply my question you can use an example with a simple set of 50 random curves by using my vector "jacobi_cst".
As final result, I want to get something like the following image taken on internet (in my case I have only one set of curves and not two as shown in the image below):
I would also add the label on the lateral colorbar and show on it, as I have already said above, 10 values of constants (the first value, the last one and then 8 values evenly spaced) with 6 decimal digits.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Blue in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



