Second X-Axis on Bottom of Contour Plot?

조회 수: 7 (최근 30일)
Michelle De Luna
Michelle De Luna 2020년 12월 1일
답변: Ameer Hamza 2020년 12월 2일
Hi everyone! I hope you are all well and safe.
Just a quick question: I have a contour plot and I'm trying to add a second x-axis to the bottom of the plot. So, in essence, both x-axes should appear at the bottom, one on top of the other. Any pointers? I tried following the instructions included in the MATLAB Help Center, but I was unsuccessful seeing as my x-axes appeared in the same position, thus jumbling up the labels. I am also unsure if there are different instructions for contour plots :(
Here's a look at what I'm working with:
contour(x, [2 4 8 12 16], 'b-', 'ShowText', 'on', 'LabelSpacing', 700)
xlim([205 245])
xticklabels([12 14 16 18 20 22 24 26 28])
xlabel('Latitude')
ylim([1 21])
yticklabels([975 925 875 825 775 725 650 550 450 350])
ylabel('Atmospheric Level (hPa)')
title('Specific Humidity')
legend('q (g / kg)')
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2020년 12월 1일
Can you show an example of where you want to place the 2nd x-axis?
Michelle De Luna
Michelle De Luna 2020년 12월 2일
Ameer,
Thank you for your response! Of course. Here is a picture of the plot. I would like the second x-axis to fall just below the original x-axis, right around where the word "Latitude" is located (so, almost as if I was pressing "enter" and inserting the second x-axis below the first).
Thanks in advance!

댓글을 달려면 로그인하십시오.

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 12월 2일
Check this example
ax1 = axes();
ax1.Position = ax1.Position+[0 0.07 0 0];
xlabel('First x-axis');
ax2 = axes();
ax2.Position = ax1.Position-[0 0.10 0 0];
ax2.Color = 'none';
ax2.YAxis.Visible = 'off';
xlabel('Second x-axis');

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by