Two different scale x axis

5 visualizzazioni (ultimi 30 giorni)
Zihan Zhu
Zihan Zhu il 11 Dic 2019
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?
profile.jpg

Risposte (1)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi il 26 Dic 2019
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!

Prodotti


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by