Semilogy Plot not showing minor tick marks
19 次查看(过去 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!