MATLAB图中不同的左右轴?

And*_*dyL 13 matlab plot

我用MATLAB绘制了一条迹线plot().我想添加一个右y轴和一组不同的刻度线(线性缩放).这可能吗?

gno*_*ice 16

关于这个密切相关的问题,有很多好的建议,尽管它们处理的情况比你的情况更复杂.如果你想要一个超简单的DIY解决方案,你可以试试这个:

plot(rand(1, 10));       % Plot some random data
ylabel(gca, 'scale 1');  % Add a label to the left y axis
set(gca, 'Box', 'off');  % Turn off the box surrounding the whole axes
axesPosition = get(gca, 'Position');           % Get the current axes position
hNewAxes = axes('Position', axesPosition, ...  % Place a new axes on top...
                'Color', 'none', ...           %   ... with no background color
                'YLim', [0 10], ...            %   ... and a different scale
                'YAxisLocation', 'right', ...  %   ... located on the right
                'XTick', [], ...               %   ... with no x tick marks
                'Box', 'off');                 %   ... and no surrounding box
ylabel(hNewAxes, 'scale 2');  % Add a label to the right y axis
Run Code Online (Sandbox Code Playgroud)

这是你应该得到的:

在此输入图像描述