last xtick label is not showing up!

22 ビュー (過去 30 日間)
Marcus Rosales
Marcus Rosales 2022 年 11 月 22 日
コメント済み: Marcus Rosales 2022 年 11 月 23 日
I am fairly uncertain why my final label is not showing up! The content of the plots themselves are not too important, but I want to place on the x-axis at x=1 the label $(\pi,\pi)$.
My code was labeling correctly till I changed it to what I have now. I am sure there is just some dumb mistake somewhere... Which are sometimes the hardest to find!
The code which contains the tick marks is in matrix ploter, and the data is generated by BdG*. Hopefully a fresh set of eyes can find the issue, and thanks!

採用された回答

Voss
Voss 2022 年 11 月 22 日
I think it's because surf doesn't render the last row or column of the matrix (so that the surface doesn't actually go all the way to x=1 but stops just before).
The problem:
M = magic(4) % 4-by-4 matrix
M = 4×4
16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
surf(M) % only 3-by-3 is shown
view(2)
colorbar()
To correct that, you can replicate the last row and column of your matrix, as in:
M = magic(4);
M = M([1:end end],[1:end end]) % 5-by-5 with last row and column repeated
M = 5×5
16 2 3 13 13 5 11 10 8 8 9 7 6 12 12 4 14 15 1 1 4 14 15 1 1
surf(M) % 4-by-4 is shown
view(2)
colorbar()
  2 件のコメント
Voss
Voss 2022 年 11 月 22 日
To check whether this is the problem, you can check the xlim of your axes. If the right limit is not-quite-1, then it's not going all the way to 1, so the label at 1 won't show up.
Marcus Rosales
Marcus Rosales 2022 年 11 月 23 日
I had that thought already but changed the range of tick marks.
I figured it out though, and it was indeed very stupid... I forgot the $ in the labels for latex mode. I at least learned something about surf now.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by