- Let 2 plot show in one figure
octave:1> t = [0: 0.01: 0.98];
octave:2> y1 = sin(2 * pi * 4 * t);
octave:3> y2 = cos(2 * pi * 4 * t);
octave:4> plot(t, y1);
[Bookmarked Mar 24, 2019 at 15:33:52]
octave:5> hold on %to hold the current plot not to be overwrite
octave:6> plot(t, y2);
octave:7> xlabel('time') %Add a label in x axis
octave:8> ylabel('value') %Add a label in y axis
octave:9> title('my plot') %Add a title
octave:10> legend('sin', 'cos') %Add a legend
octave:11> cd 'Downloads'
octave:12> print -dpng 'myplot.png' %output the plot
octave:13> close %close previewer
myplot.png
- Output 2 figure
octave:14> figure(1); plot(t, y1);
octave:15> figure(2); plot(t, y2);
- subplot
octave:27> subplot(1, 2, 1); %divides plot in 1 * 2 grid, access the first element
octave:29> plot(t, y1);
octave:30> title('sin');
octave:31> subplot(1, 2, 2); %divides plot in 1 * 2 grid, access the second element
octave:32> plot(t, y2, 'r');
octave:33> title('cos');
octave:34> print -dpng 'my subplot.png'
octave:35> close
my subplot.png
- axis: to range the axis in the figure:
axis(xmin, xmax, ymin, ymax)
-
clf: clear a figure
-
Print a figure stand a matrix(different color stand for different value)
octave:42> A = magic(15);
octave:45> imagesc(A), colorbar, colormap gray;
octave:46> print -dpng 'imagesc.png'
imagesc.png
网友评论