I want to plot three plots in one for comparison in deviations. I use hold on, but due to the fact that the graphs are spread across the y-axis it looks like this:
How can I make the plots start from one point? Is there a built-in solution for that, or will I have to manually shift them?
Thanks in advance!
If you are not worried about the absolute values on the y axis, you could always do something like
plot(x, y - y(1));
instead of plot(x, y), assuming your y is a vector.
Related
i want to plot Y versus the corresponding values in X in MATLAB,and i want to see the points (x,y) just when x=5,10,2000.because these values are really far apart the graph is not good.what must be done with my X axis?
thank u.
If you just want to have the 5,10,2000 values plotted, then maybe do:
plot(X([5,10,2000]),Y([5,10,2000]),'o')
or else you can try plotting the whole thing, but represent the X-axis as log:
semilogx(X,Y)
HTH!
I think this might be simple. If we simply plot a vector in MATLAB, it will show it normally, going left to right. That is, the x-axis will have 'time'.
But, I would like to show it going from up to down instead in the plot. How can I do that? In other words, I want the amplitude to be shown on the x-axis, and the time to be shown on the y-axis.
Thanks.
Create a vector with the coordinates of your time vector t and flip x and y in your call to plot:
plot(t, 1:length(t));
I am trying to plot on the same figure the evolution of a function f, with argument x in ]0,1]. I would like to see both the evolution of f far away from 0 and close to 0, on the same figure, with one x axis.
For now I only have two different figures, one using plot with x=[0.1 ... 1], and one using semilogx with x=[1e-9 1e-7 1e-5... 0.1]. I would like to have both graphs on the same figure, with the x axis being logarithmic at the beginning, then linear after a certain x0 (let's say x0=0.1).
I do not want something using plotxx since I want only one x axis.
Do you know if this is possible?
Thank you for your time and help.
Just plot your y vector without specifying the x vector, this will get you a uniformly spaced plot, then use XTick and XTickLabel to make it work. For example,
x1=logspace(-10,-1,10);
x2=linspace(1,10,10);
y1=x1.^0.25;
y2=1./x2;
plot([y1 y2],'-x')
xlabels=num2cell([x1 x2]);
set(gca,'XTick',1:numel(x1)+numel(x2),'XTickLabel',xlabels)
If you want to use Latex to format tick labels, you'll need to download a function from the Matlab File Exchange.
I have two vectors of the same length and I'd like to treat the first as X values and the second as Y values and present (x,y) points on a graph.
How do I do this simple thing in Matlab?
Thanks!!!
It seems that it is just plot(x, y) what you need.
For example to plot 'dots' use plot(x, y, '.'). For more examples of markers to use, see the attached link.
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.