How to Equally distribute the data point on the graph along x axis - matlab

I have some datas, say from [0.1:0.1:0.9]+[1:1:10].
If I use scatter to plot it, it looks like this.
However, it want the points equally distribute along the axis, anyone can tell me how to do it? What I mean is the distance between data points in [0.1-0.9] are the same with [1-10] on the graph respect to x-axis.

If your data is contained in vectors x and y, use
plot(y,'o')
instead of plot(x,y,'o') or scatter(x,y).
If you want to label the x axis, use something like
set(gca,'xtick',1:length(y),'xticklabel',[.1:.1:.9 1:10])
Or you might want a subset of the labels, for example:
set(gca,'xtick',1:2:length(y),'xticklabel',[.1:.2:.9 2:2:10])

Related

Is there a way to increase density of data of scatter data?

I have this x y data:
I would like to increase the density of points by closing small gaps. How do i go about. I still want to preserve the structure of the points.
It depends on what you mean by 'closing gaps'.
if you mean that you want to make the data seem more grouped without actually adding more data points, then you might find the 'LineWidth' argument to be useful. If used currectly it increases the width of each marker in the scatter plot, which will make the data seem more grouped and with less gaps.
to use it, write the scatter code line as follows:
scatter(X, Y, 'LneWidth', width_number)
replace 'width_number' with different values and see the effect.

Shifting plots on y-axis in MATLAB

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.

having X axis in special discrete values

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!

Matlab: Labelling the y axis

I have plotted a dot raster plot divided into various segments, which I would like to label. In my case, I have different attenuation values for the same frequency value and want to label the attenuation values in the y-axis.
It's a little unclear exactly what your trying to do but if you mean to label the entire axis using:
ylabel('sometext','fontsize',12);
If you mean to label specific ticks on the axis try using something like :
set(gca,'Ytick',[0:3],'YtickLabel',{'hello','world','foo','bar'});
Edit:
You would want to do something like this.
set(gca,'Ytick',[1:20:120],'YtickLabel',{'label1','label2','label3',etc...});

MATLAB: Plotting Contours at Specfic Points (x,y)

I'm currently producing a contour plot using
contour(x,y,z)
However, I would like to specify some additional contour lines to the ones provided.
I understand that I can use contour(x,y,z,v) where v is some vector containing values of the contour levels I would like but I don't really want to use this since I don't know exactly the levels.
Instead is it possible to plot the contour that goes through a specific point (x,y)?
Thanks.
You can overplot a second contour with a single, specific value for the contour, optionally specifying parameters like line width to make it obvious:
contour(x,y,z)
hold on
lev = z(n,m); % find the value you want in z
contour(x,y,z,lev,'Linewidth',2);