2017-04-21 4 views
0

Je voudrais générer des limites en utilisant xfpoly et les enregistrer en utilisant xs2pdf. Ensuite, je veux afficher un graphique de 2 fonctions dans ces limites, ajouter une légende à ces fonctions et enregistrer à nouveau l'image.Scilab - Légende UNIQUEMENT pour un ensemble spécifique de fonctions

Mon code suit ...

clear; clc; xdel(winsid());  

t = -2:0.01:2; 
x_1 = t.^2; x_2 = t.^4; 

xfpoly([-3 -2 -2 -3], [0 0 16 16], color('grey')); 
ax = gca(); 
ax.auto_clear = 'off'; ax.data_bounds = [-3, 0; 3, 3]; 
ax.box = 'on'; 
ax.axes_visible = ['on','on','off']; ax.tight_limits = ['on','on','off']; 
xfpoly([2 3 3 2], [0 0 16 16], color('grey')); 
xfpoly([-1 1 1 -1], [1 1 16 16], color('grey')); 

xs2pdf(gcf(), 'fig_1'); 

plot2d(t, [x_1', x_2'], [color('green'), color('red')]); 
legend(['t^2'; 't^4']); 
leg_ent = gce(); 
leg_ent.text = ['';'';'';'t^2'; 't^4'] 

xs2pdf(gcf(), 'fig_2'); 

Répondre

0

Atilla's answer m'a amené à cette solution en utilisant la commande pause:

clear; clc; xdel(winsid());  

t = -2:0.01:2; 
x_1 = t.^2; x_2 = t.^4; 

plot2d(t, [x_1', x_2'], [color('green'), color('red')]); plot_1 = gce(); 
legend(['t^2'; 't^4']); leg_1 = gce(); 
plot_1.visible = 'off'; leg_1.visible = 'off'; 

xfpoly([-3 -2 -2 -3], [0 0 16 16], color('grey')); 
xfpoly([2 3 3 2], [0 0 16 16], color('grey')); 
xfpoly([-1 1 1 -1], [1 1 16 16], color('grey')); 
ax = gca(); 
ax.box = 'on'; 

xs2pdf(gcf(), 'fig_1'); 
// pause 
plot_1.visible = 'on'; leg_1.visible = 'on'; 
xs2pdf(gcf(), 'fig_2'); 
+0

Si ma réponse vous a aidé, vous pouvez l'augmenter. Je suis content que je puisse aider. – Attila

+0

Je serais ravi d'upvote. Mais ma réputation est trop faible pour le faire ... – ska109

0

Voulez-vous quelque chose comme ça?

clear; 
clc; 

t = -2:0.01:2; 
x_1 = t.^2; x_2 = t.^4; 

scf(0); 
clf(0); 
//plot the curves first to make legend easier 
plot2d(t, [x_1', x_2'], [color('green'), color('red')]); 
legend(['t^2'; 't^4']); //the first two elements are the curves, so no neet to modify 
ax = gca(); 
ax.auto_clear = 'off'; 
ax.data_bounds = [-3, 0; 3, 3]; 
ax.box = 'on'; 

xfpoly([-3 -2 -2 -3], [0 0 3 3], color('grey')); 
xfpoly([2 3 3 2], [0 0 3 3], color('grey')); 
xfpoly([-1 1 1 -1], [1 1 3 3], color('grey')); 


scf(1); 
clf(1); 
xfpoly([-3 -2 -2 -3], [0 0 3 3], color('grey')); //ymax sholud be 3, not 16 
xfpoly([2 3 3 2], [0 0 3 3], color('grey')); 
xfpoly([-1 1 1 -1], [1 1 3 3], color('grey')); 
ax = gca(); 
ax.auto_clear = 'off'; 
ax.data_bounds = [-3, 0; 3, 3]; 
ax.box = 'on'; 
+0

Oui, je dois créer ces 2 parcelles. Mais (à des fins d'enseignement) dans l'ordre tel qu'il est écrit dans ma question - les limites de gris d'abord, puis ajouter 2 courbes. Le problème est que je crée d'abord 5 graphiques avec des limites et ensuite j'ajoute 5 courbes de 2 courbes chacune. – ska109