matlab multiple x axis one below another

和自甴很熟 提交于 2019-11-26 17:04:23

问题


I am trying to create a matlab plot with multiple x-axis one below another and just one y-axis.

I have looked through the Mathworks file exchange and there are only suggestions/scripts for multiple y-axis. I would like to achieve something like this question for R.


回答1:


Here is an example solution if you only need a second axis for showing a different scale (Jeff_K's solution but more worked out):

first_axis = gca;
sqz = 0.12; %// distance to squeeze the first plot
set(first_axis, 'Position', get(first_axis, 'Position') + [0 sqz 0 -sqz ]);
ax2 = axes('Position', get(first_axis, 'Position') .* [1 1 1 0.001] - [0 sqz 0 0],'Color','none');
scale_factor = 42; %// change this to your satisfaction
xlim(get(first_axis, 'XLim') * scale_factor);
set(ax2, 'XScale', get(first_axis, 'XScale')); %// make logarithmic if first axis is too



回答2:


If you don't actually need to plot data on the secondary axes, and are just using them to show scale (like the example you linked to), you can do it simply by adding a second (or third, etc.) axis at the appropriate position, and setting the height very small:

ax2 = axes('Position',[0.1 0.1 0.8 0.001],'Color','none')

Then set the tick labels appropriately.




回答3:


you need to use a patch function for this. Look here for more details: http://www.mathworks.com/matlabcentral/fileexchange/26550-myplotyy



来源:https://stackoverflow.com/questions/11531762/matlab-multiple-x-axis-one-below-another

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!