开发者

How to plot 2 graphics in one picture?

I have the followin开发者_C百科g code to plot one graphic:

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

and then this one to plot another:

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

Now I'd like to be able to plot both ones in the same place. How can I accomplish that?


Solution#1: Draw both set 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 seperate axes side-by-side on the same figure

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


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

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


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

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

becomes

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜