Semilogy Plot not showing minor tick marks
조회 수: 20 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (2개)
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
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.
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
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 Exchange에서 Orange에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!