Semilogy Plot not showing minor tick marks

19 ビュー (過去 30 日間)
Daniel
Daniel 2011 年 11 月 14 日
コメント済み: Bruce Rodenborn 2023 年 7 月 16 日
Hi,
I am having a problem with my semilog plot showing minor tick marks. It seems that there should be an obvious mistake that I've made but I can't seem to find one. Here is a simple example using a well known plot to illustrate my problem.
T = 200:10:1000;
h = 6.626 * 10^-34;
k = 1.38 * 10^-23;
Si_mn = 1.08 * (9.109 * 10^-31);
Si_mp = 0.81 * (9.109 * 10^-31);
Si_Eg = 1.12 * 1.602 * 10^-19;
Ge_mn = 0.56 * (9.109 * 10^-31);
Ge_mp = 0.29 * (9.109 * 10^-31);
Ge_Eg = 0.66 * (1.602 * 10^-19);
Si_NC = 2 * ((2 * pi * Si_mn * k .* T) / h^2 ).^(3/2) / 100^3;
Si_NV = 2 * ((2 * pi * Si_mp * k .* T) / h^2 ).^(3/2) / 100^3;
Ge_NC = 2 * ((2 * pi * Ge_mn * k .* T) / h^2 ).^(3/2) / 100^3;
Ge_NV = 2 * ((2 * pi * Ge_mp * k .* T) / h^2 ).^(3/2) / 100^3;
ni = sqrt(Si_NC .* Si_NV) .* exp(- Si_Eg ./ (T .* k .* 2));
ni(2,:) = sqrt(Ge_NC .* Ge_NV) .* exp(- Ge_Eg ./ (T .* k .* 2));
semilogy(1000./T,ni)
Also, I am fairly new to MATLAB so if there is a way to optimize this code, any and all input would be appreciated.
Thanks,
Daniel

回答 (2 件)

Sarah Wait Zaranek
Sarah Wait Zaranek 2011 年 11 月 14 日
The X Minor ticks are off by default. This should turn them back on.
ax = gca; % grabs current axis
set(ax,'XMinorTick','on') % sets Minor X Ticks to display
I am not sure why the Y Minor Ticks aren't showing up, but this techincal solution would work where you hardwire the ticks in that you want.
  2 件のコメント
Jose M. Mier
Jose M. Mier 2012 年 8 月 30 日
I'm using MatLab 2010a (v. 7.10.0) and I'm having a similar issue. I have a contourf plot with a log scale on the y axis. I get the minor tick marks on the plot normally. The problem comes when saving the figure (saveas), the minor tick marks don't show up in the jpg figure, while the major tick marks are still there. I tried back and forth top and bottom 'Layer' and on and off 'YMinorTick', but still the same. The matlab figure shows them correctly but the problem is the saved jpg figure. However, when I move the tick marks to the outside, they show up in the saved jpg figure. Something tells me that for some reason the contourf is getting on top of the minor ticks when the saveas command is called. Any ideas on how to solve it? Thanks.
K E
K E 2012 年 9 月 10 日
Start a new question and you are more likely to get an answer.

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


Bruce Rodenborn
Bruce Rodenborn 2023 年 7 月 16 日
編集済み: Bruce Rodenborn 2023 年 7 月 16 日
This does not work. I if I set the ylimits in the plot, set minor ticks on, it changes its behavior in an uncontrolled way. The minor ticks disappear based on setting the font size of the axis. The plot also ignores the assighment of ytick locations. It's a bug.
  1 件のコメント
Bruce Rodenborn
Bruce Rodenborn 2023 年 7 月 16 日
I remedied the problem by plotting data in the positive y direction. Apparently the bug occurs when you plot negative values using semilogy.

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

カテゴリ

Help Center および File ExchangeOrange についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by