Different right and left axes in a MATLAB plot?

后端 未结 6 824
我在风中等你
我在风中等你 2020-12-05 15:28

I plot a single trace in MATLAB with plot(). I\'d like to add a right-y axis with a different set of tick marks (scaled linearly). Is this possible?

6条回答
  •  执念已碎
    2020-12-05 16:16

    Jiro's solution is good (file Exchange function), however, it does not allow to use Matlab's built-in plot functions (bar, scatter, etc.), and you have to use plot2axes instead. Matlab's own help gives the solution to have two axes on any type of plots: ax2 = axes('Position',get(ax1,'Position'),... 'XAxisLocation','top',... 'YAxisLocation','right',... 'Color','none',... 'XColor','k','YColor','k');

    Look at: http://www.mathworks.com/help/techdoc/creating_plots/f1-11215.html

提交回复
热议问题