How to build 2 graphics in one picture?

I have the following code to build one chart:

plot(softmax(:,1), softmax(:,2), 'b.') 

and then this one to build another:

 plot(softmaxretro(:,1), softmaxretro(:,2), 'r.') 

Now I would like to be able to build both in the same place. How can i do this?

+4
source share
3 answers

Solution # 1: Draw both sets of points on the same axes

 plot(softmax(:,1),softmax(:,2),'b.', softmaxretro(:,1),softmaxretro(:,2),'r.') 

or you can use the hold command:

 plot(softmax(:,1), softmax(:,2), 'b.') hold on plot(softmaxretro(:,1), softmaxretro(:,2), 'r.') hold off 

Solution # 2: draw each on separate axes side by side in the same drawing

 subplot(121), plot(softmax(:,1), softmax(:,2), 'b.') subplot(122), plot(softmaxretro(:,1), softmaxretro(:,2), 'r.') 
+7
source

You need to use the HOLD command so that the second chart is added to the first:

 plot(softmax(:,1), softmax(:,2), 'b.'); hold on; plot(softmaxretro(:,1), softmaxretro(:,2), 'r.'); 
+3
source

You can also draw one on top of the other by slightly editing @amro # 2's solution:

subplot (121), graph (softmax (:, 1), softmax (:, 2), 'b.') subtitle (122), section (softmaxretro (:, 1), softmaxretro (:, 2), 'r. ')

becomes

subplot (211), graph (softmax (:, 1), softmax (:, 2), 'b.') (212), plot (softmaxretro (:, 1), softmaxretro (:, 2), 'r.' )

0
source

All Articles