incomplete minor gridlines in semilogx plot
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I would like to plot a semi-log plot with gridlines. The problem is that the plot needs to have a slightly elongated aspect ratio, and when I switch the aspect ratio the gridlines disappear. For example:
x = 10.^(-9).*[2,3,4];
y = [3,4,5];
figure(1); close(gcf); figure(1);
pos = get(gcf,'Position'); set(gcf,'Position',[pos(1),pos(2),0.5.*pos(3),pos(4)]);
semilogx(x,y,'-ok'); grid on; xlim([3*10^(-11),4*10^(-8)]);
no longer has minor xaxis gridlines even though XMinorGrid = on and XMinorTick = on. I can add most of the gridlines by altering the code to be:
x = 10.^(-9).*[2,3,4]; y = [3,4,5];
figure(1); close(gcf); figure(1);
pos = get(gcf,'Position'); set(gcf,'Position',[pos(1),pos(2),0.5.*pos(3),pos(4)]);
semilogx(x,y,'-ok'); grid on; xlim([3*10^(-11),4*10^(-8)]);
set(gca,'XTickMode','manual'); set(gca,'XTick',10.^[-11:1:-7]); %change
but I'm still missing the minor gridlines to the far right. Any ideas?
Thanks!!
0 comentarios
Respuesta aceptada
dpb
el 24 de Jul. de 2014
AFAIK only drawing them manually or increasing the width. Here experimentally I've determined that the internal logic will draw them with
pos(3)>=325;
anything smaller they aren't displayed. You could experiment and see where you lose them and see if can stand the size to make them show automatically. I did something like
for i=1:10,pos(3)=pos(3)-2;set(1,'Position',pos),pause(2),disp(pos(3)),end
and ^-C'ed out when it failed from a starting point that displayed them to find the magic number.
Alternatively, to draw the missing ones directly if can't afford any more real estate at all,
xl=repmat([2:3]*1e-8,2,1);
yl=repmat([3 5].',1,2);
line(xl,yl,'linestyle',':','color','k')
Obviously in general retrieve the limits and compute the locations based on the actual plot parameters instead of using the fixed values specific for the particular case here...
1 comentario
Más respuestas (1)
dpb
el 24 de Jul. de 2014
Editada: dpb
el 24 de Jul. de 2014
It's a fignewton of the handle graphics and incomplete log cycles(*). AFAIK other than drawing the lines manually, all you can do is
xlim([3e-11),1e-7])
and they'll reappear. I've noticed this in the past--it'll complete them as long as the upper limit is the next power of 10 so you can chop off on the left but not on the right.
Mayhaps that's worthy of a bug report/enhancement request--I've not done so; don't know if it has been submitted previously or not.
ADDENDUM
(*) In conjunction with narrow-width plotting. At a certain point they do show up again despite the incomplete log cycle. It seems this may well be a bug rather than an intended feature; probably worth report to official TMW support at www.mathworks.com
Ver también
Categorías
Más información sobre Time Series Events en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!