Filter löschen
Filter löschen

Semilogy Plot not showing minor tick marks

22 Ansichten (letzte 30 Tage)
Daniel
Daniel am 14 Nov. 2011
Kommentiert: Bruce Rodenborn am 16 Jul. 2023
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

Antworten (2)

Sarah Wait Zaranek
Sarah Wait Zaranek am 14 Nov. 2011
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 Kommentare
Jose M. Mier
Jose M. Mier am 30 Aug. 2012
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 am 10 Sep. 2012
Start a new question and you are more likely to get an answer.

Melden Sie sich an, um zu kommentieren.


Bruce Rodenborn
Bruce Rodenborn am 16 Jul. 2023
Bearbeitet: Bruce Rodenborn am 16 Jul. 2023
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 Kommentar
Bruce Rodenborn
Bruce Rodenborn am 16 Jul. 2023
I remedied the problem by plotting data in the positive y direction. Apparently the bug occurs when you plot negative values using semilogy.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by