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!