Change the distance between x-axis lables of a plot in MATLAB - matlab

I plot the following figure and I want to decrease the distance between x axis labels for example the distance between 1 and 2 or 2 and 3.
I do not know how can I do that !!!
I found these pages 1 and 2 but I could not know how should I write those codes without getting exceptions. Since, I am not familiar with Matlab environment.

The simple way is resize your figure or change it's position. It would change the distance.

Related

Offset lineplot from Y-axis

I am working with a data stream and for different time points in this stream I have density estimates over a fixed set of X values.
Each of these sets of estimates would look something like this
I'd like to plot multiple curves like this sideways, similar to how it's done in this answer
I've looked through the documentation regarding plotting but didn't find a straight-forward solution for it.
While it's easy to turn such a plot sideways by simply switching the axes, I didn't find a possibility to offset this from the Y-axis
Does anyone have an idea how to tackle this?
Instead of plotting
plot(x,y)
plot
plot(k+y,x)
where k is the location of the plot along the x axis (2 or 4 in your example).

Getting a cross-section from power-spectrum

I am currently trying to use spectral-methods to analyse topographic landscapes.
When i FFT the landscape and plot the power-spectrum. From the power-spectrum an orientation of the structures in the landscape can be found.
2D power-spectrum:-
In this power-spectrum, i would like to make a cross-section.
This is easy when the peak amplitude orientation is along the x or y-axis.
But for this area (and others), this is not the case.
Cross-section from another area - orientated along the y-axis:-
My problem is i want to make a cross-section along the peaks in 1, and i just cant seem to figure it out how.
If anyone could point me towards some solution for this. Been stuck here for a couple of days now.
Edit 1
I would like the cross-section, to be a line along the peak orientation.
Edit 2
Improved the first image to show where i want my cross-section
My solution was, as GameOfThrows suggested:
Pick 2 (or more) points on the orientation i want
used Least squares on the points to create the line
Setup a meshgrid for the interpolation.
Use the interp2 function on the new line.
define a proper axis for the section
In my final cross section i ended up having multiple lines in it, that way i was sure to hit the max amplitudes.
i was a little with the answer to my question, but i have been busy :)
You can use ginput built-in matlab function to store 2 (x,y) coordinates of your power spectrum and then use this values to delimit a profile to be interpolated.

Changing axis values on Matlab figure/graph output?

I have a graph that automatically has x and y axis/values. However, I want to completely get rid of those and put into my own custom values, without changing the appearance of the graph at all.
Currently the x and y scales are pixel coordinates of the image, but I want to get rid of it and make them into centimeters so someone can better understand how large the image is that they are looking at...
You can change the units of an axes with this command:
set(YourAxesHandles,'Units','centimeters');
and then play around with the scaling/values/whatever you want:
set(YourAxesHandles,'XMin',[min max]);
set(YourAxesHandles,'YMin',[min max]);
set(YourAxesHandles,'XTick',[min:increment:max]);
and so on. Is that what you meant?
I found how to do this, check it out if you want:
% I want 8 intervals, so I divide 272 (number of pixels in X)
% by 34 to get 8 splits
set(gca,'XTick',[0:34:272])
% specify the label displayed at each tick mark
set(gca,'XTickLabel',[-4:4])
Thanks a lot, you made me look in the right direction.

Gnuplot how plot 3d figures in a style similar to Matlab

I found gnuplot's 3d figure not very attractive.
Is there a way to product a figure looks like this one:
The key points are:
1) less density of x and y tics
2) grids
3) tics bars toward outside the figure.
Here is what I have tried (dowwnload the script here: https://dl.dropboxusercontent.com/u/45318932/gnuplot2.plt):
I know how to manually set x/y tics but I do not want to as it is not a general solution. Unless you can set x and y tics dynamics according to your data.
Can you help me finish the second figure in the style of the first one (matlab)?
This is the best I can get, using gnuplot:
The code is here: https://github.com/mleoking/JavaGnuplotHybrid/blob/master/JavaGnuplotHybrid/src/org/leores/plot/JGnuplotDemo.java

Overlapping data points and spacing

I have a set of data that I plot but the points on the graphs are so closed to each other that you can't see them well nd neither their values because even when I zoom in I can't get to them all. Now what I want to do is to space them out without changing their actual values on the graph. Is the a function or any other ways to do that? I've tried changing the axis and the scale but it didn't help. Mostly those points are in the Y direction. Please help What I really mean is though these points are closed to each other I'd like to create and interval between them so they don't pile up on each other
You can make the vector you are trying to plot to be more sparse taking points after some defined intervals:
plot(x(1:10:end),y(1:10:end))
In this example, I plotted each tenth point. Does it help?