How to scale `X` axis and include the data -- Matlab - matlab

I want to plot on X axis the points [8,16,32,64,128,512] and on Y axis the corresponding values to these points. I have done the following, but eventhough I have specified the X axis and selected the colum values for it, I am not getting the numbers [8,16,32,64,128,512] displayed on X axis.

Use xticks([8 16 32 64 128 256 512]) right after plot (or you may have to get handle of the axe) to set display ticks in X axis

Related

How do I customize dual axis values?

I want to plot 2 variables in my worksheet.X variable vs Y variable. The Y variable is composed of 3 sub-variables y1,y2,y3 which when summed up result to Y. I have expressed y1,y2,y3 as percentages of Y say Y=45(100%) and y1=35%,y2=40%,y3=25%.How do I plot X vs Y with the Y axis value being 45 and not 100%?
I have been to plot the measure values of Y(y1,y2,y3) but now the axis values are automatically generated from 0 to 100%. What I want is the real axis values to be displayed 0 to 45.
I want the axis to be real values of Y(45) but the sub_variables (y1=35%,y2=40%,y3=25%)
There are a couple of things you can do here.
Click on the secondary axis and select "Synchronize axis". This
will ensure that the secondary axis is tied to the scope of the
primary axis.
You can manually edit either/both axis by right clicking on them and setting the axis values manually.
Beyond this, it might be how you are setting up your viz. If you could provide a picture/sample data it would be helpful.

How to set x axis values in MATLAB

I'm working with some signal. The signal has some length (time) and I devided it into 200 pieces and made some operations over them. The results are saved in matrix, so the matrix has one of the dimensions 200 and if I use imagesc() on it, to make results visualy readable, the x axis is from 0 to 200. But that does not correspond to time. The time is function of the values in x axis.
t = 640 * x
I need to make values in x axis to correspond to time. Is there any way, how to do this?
Use set and set the XTick and the XTickLabel properties accordingly. Assuming your image is already open, do this:
set(gca, 'XTick', 0:20:200);
set(gca, 'XTickLabel', 640*(0:20:200));
I used increments of 20 so that you don't clutter the x-axis. Modify the 20 to suit your tastes.

How to change axis scale on imagesc in Matlab

I have a 15x15 image of a grid of numbers which I have shown using imagesc. However, the axis goes up to 450 in both directions, when I only want it to go up to 15. I tried:
axis/30;
But that doesn't do anything? All I want to do is divide the x and y axes by 30!
The problem is, I presume, that although your image shows 15 numbers along in each axes, the total size of your image in pixels is 450 x 450 - and this is what imagesc is using.
So, what you really have is an image with 15 x 15 blocks of 30 x 30 pixels. You can set the axes ticks and labels manually using XTick and XTickLabel:
atick = 15:30:415; %assuming you want the ticks in the centre of each block
set(gca,'XTick',atick);
set(gca,'XTickLabel', 1:15);
set(gca,'YTick',atick);
set(gca,'YTickLabel', 1:15);

Custom X axis in core plot

I have this X axis in my sample project on Core Plot and I wonder how I can customise it a little bit. As you can see it currently has only 3 values on the X axis:
But the values of the two plots I have (the black and grey ones) go far beyond the number of points in the X axis (29 against 3 points). Because of the fact that I have 3 points, only 3 values for each plot are shown.
I would like to keep displaying the remaining 3 points on the axis but accommodate all my 29 events for my plots (they could be displayed in the middle of 1 and 2 point).
How can I do this?
Increase the length of the xRange of the plot space. The value needed depends on the plot data.

Matching axes scales

I have 3D data plotted using the 'plot3' function. I would like to constrain the Y and Z axes such that they are equal in scale. The X axis should be automatically scaled as usual.
I know from here that I can make the X axis be the only one to be automatically scaled by using the command:
axis 'auto x';
However, this causes the Y and Z axes to be plotted from 0 to 1 only; my data often exceeds this in all axes. What I'm looking for is a plot which contains all the data in a single view, but with the smallest of the Y or Z axes scaled down so that the Y and Z axes are equivalent in scale.
Try daspect.
plot3(5*rand(10,1),10*rand(10,1),rand(10,1))
tmpAspect=daspect();
daspect(tmpAspect([1 2 2]))
daspect() returns the current aspect ratio as produced by axis 'auto'.
daspect(tmpAspect([1 2 2])) then enforces that y and z have the same scale.
How about
axis equal
or even
axis tight
axis equal
both after the plot has been drawn.
Is this what you mean?
Type help axis at the Matlab command prompt for more capabilities of the axis function.