Two different scale x axis
이전 댓글 표시
Hi, I'm trying to make a plot like that. A plot include several subplots with each own x axis but share one x and y axis. I guess it could be done by a combination with plotxx and subplot. But I haven't figured out how to do it. How can I make this work?

답변 (1개)
Vinai Datta Thatiparthi
2019년 12월 26일
Hey Zihan!
There's no ready-to-use function in MATLAB that supports what you're asking, but there are certainly some workarounds that I can think of -
- Instead of plotting the three subplots against a single y-axis, you could split them into three separate plots -
figure
subplot(131);
ax1 = gca;
set(ax1, 'xtick', [], 'ytick', []); % Suppress the x-axis labels
xlabel('DateTime1'); % Date
ax1top = axes('Position', ax1.Position, 'XAxisLocation', 'top'); % Your Concentration Axis on the top
Repeat this block of code three times to get your output
- If you want your subplots to be stacked up against each other, then on the figure, select the "Edit Plot" option and select the subplots - you can now move them around using the arrow keys. In this case, suppress the y-axis option for the 2nd and 3rd subplots -
set(gca, 'YColor', 'none');
- Alternatively, consider using the function stackedplot. You can have the properties "concentration" and "date" on the y-axis, and "Altitude" on the x-axis.
Hope this helps!
카테고리
도움말 센터 및 File Exchange에서 Axes Appearance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!