I have plotted to vectors against each other, and they are already logarithmic and everything is fine with that. But now that I have my plot i want the grid to be logarithmic. I write "grid on" in my code, and I think there should be a way to do this in the plot, but I can't remember how. How do I make the grid logarithmic?
If you use loglog, semilogx or semilogy instead of plot, the grid will automatically be on a log scale for the corresponding axes when using grid on.
If you have already plotted the axes, you can execute the following on the command line:
set(gca,'yscale','log') %# to set the y-axis to logarithmic
set(gca,'xscale','log') %# to set the x-axis to logarithmic
Have a look at axes properties to find out what else you can modify.
Related
I have plotted to vectors against each other, and they are already logarithmic and everything is fine with that. But now that I have my plot i want the grid to be logarithmic. I write "grid on" in my code, and I think there should be a way to do this in the plot, but I can't remember how. How do I make the grid logarithmic?
If you use loglog, semilogx or semilogy instead of plot, the grid will automatically be on a log scale for the corresponding axes when using grid on.
If you have already plotted the axes, you can execute the following on the command line:
set(gca,'yscale','log') %# to set the y-axis to logarithmic
set(gca,'xscale','log') %# to set the x-axis to logarithmic
Have a look at axes properties to find out what else you can modify.
I have two plots. The x-axis for both is same, however the y-axis is different. I would like to plot both plots in one plot in a way that they share the same x-axis. x-axis represents time for both graphs. Any suggestions how to do that instead of plotting each one alone. The following picture shows what I'm looking for.
you can use subplot and delete the x-axis tick labels of the top one, for example:
x=rand(1,100);
subplot(2,1,1);
plot(1./x);
ylabel('Label 1')
set(gca,'XTickLabel',[])
subplot(2,1,2);
plot(x)
ylabel('Label 2')
xlabel('x Label')
If you want the plots to be closer to one another you can use one of the FEX files such as subplot_tight etc (for example this one , or this one)
Or you can just use axes...
Is it possible to create a semilog plot (semilogx, semilogy, loglog) within a semilog plot? I need to have a zoom-in plot. Most solutions I found only solve for linear scale but not log scale.
Try using axes, for example:
x = linspace(0,1);
figure(1)
% plot on large axes
semilogy(x,1./x)
% create smaller axes in top right, and plot on it
axes('Position',[.55 .55 .33 .33])
box on
loglog(x,exp(x))
i am trying to plot "scatter" on top of "imagesc" which dosen't work. However, i can plot "scatter" figure separately. I even tried "hold all" instead of "hold on". Can someone help me out? Thank you.
figure(2)
imagesc(lat1,height,scatter0')
hold on;
scatter(lat1,top2,'k')
title('2012_12_4')
colormap(colors)
axis xy
It is probably x-y limits that are not matched, or that the z-values that are not properly normalized to plot side by side. The normalization is important because imagesc and scatter will share the same colormap. Other than that, your code works nicely for me. For example, I'm normalizing in the range [0,1] the "z" values of both plots:
load seamount
m=peaks(200);
m=(m-min(m(:)))./(max(m(:))-min(m(:)));
imagesc([0.996 1.0005],[1,1.012],m);
hold on ;
z=(z-min(z(:)))./(max(z(:))-min(z(:)));
scatter(x./max(x(:)),y./max(y(:)),5,z);
Is it possible to make a plot in matlab that does not actually take the logs of the values? I'm plotting wide ranges of values and when I try to make a log plot of them, those below 1 become negative. I would just like it to plot the values on a log scale without taking their logs.
Alternatively, set(gca,'XScale','log') if you have your plot already.
Yes, it is possible. Use the loglog command.
The example from the Mathworks website:
x = logspace(-1,2); % generate a sequence of points equally spaced logarithmically
loglog(x,exp(x),'-s')
grid on
If you do not want both axes to be log scale, use semilogx or semilogy.
So, you want to plot liner data on logarithmic axes? You can exponentiate you values before using the log plot. This way the point p=(10,3) will plot at the x=10 position.