Axis selection in planes

This should be pretty simple, although I could not find a solution in the Matlab docs.

I need to build two or more datasets that can be placed in two different ranges. Therefore, I can use plotyy to control this.

What I want to do, allows, once created plot, rewrite or just add traces to one of the two axes selectively. I tried to catch the parameters returned by the plot, but I could not decrypt them.

Any help is appreciated.

+4
source share
2 answers

The MATLAB documentation on plotyy states that

 [ha, h1, h2] = plotyy(...) 

returns the descriptors of two axes created in ha , and the descriptors of graphical objects from each graph in h1 and h2 . ha(1) is the left axis, and ha(2) is the right axis.

So, the first argument returned by plotyy is the handle to each of the created axes. To plot on the left axis, use plot(ha(1), x, y) and to plot on the right axis use plot(ha(2), x, y) .

If you don't need graphic descriptors, you can simply use ha = plotyy(...) . Otherwise, h1 and h2 returns the descriptors of the lines (or other graphic object) plotted as a result of calling plotyy . So, following the documentation example, setting line styles for two lines can be done as follows:

 set(h1, 'LineStyle', '--') set(h2, 'LineStyle', ':') 
+3
source

The first output of PLOTYY is the axis handle vector.

 AX = PLOTYY(..) 

AX(1) will be the handle to the first axis. AX(2) will be the handle to the second axis.

To add a graph to one of the axes, simply use PLOT or LINE.

 plot(AX(1), ...) line('parent',AX(1),'xdata',...) 
+2
source

Source: https://habr.com/ru/post/1394620/


All Articles