MATLAB, turning numbers off on plot - matlab

I'm pretty familiar with all of the axis properties for a matlab plot, but I can't seem to find any of them that actually effect displaying the numbers or not. I have a plot where numbers are pretty meaningless, they're only there to get a good visual representation of what I'm working on. So, it would be better if I could just have the numbers gone compeltely. Is there a way to do this? Thanks. (No not the tick marks or any of that, the actualy NUMBERS! =))

It's not the tick marks you're after but the tick labels. Just set them to empty lists:
set(gca,'XTickLabel', [], 'YTickLabel', [])

Related

Representing legend in matrix form in Matlab

I am supposed to represent the legend as a 2X3 matrix including the line style in the matrix (like dashed represent one curve, straight line represents other curve).
I did lot of google search but did not really get anything. Legend flex also didn't work.
Can you kindly suggest how can I align my legend data manually in a matrix form ??
Well, I realized there are no such formats supported on Matlab legend formats. Therefore, I ended up editing the text box with extra spaces and symbols. However, I still believe there is a way to insert a matrix on the plots like legends.

Why is errorbar whisker length dependent on X

I am running a simulation in Matlab 2015 which creates data each round, so I am plotting a number of single errorbar series individually. Here's a sample code and the output plot:
figure
xlim([0 30])
hold on
errorbar(1,2.0,1.9,16.5,'x')
errorbar(15,2.0,1.9,16.5,'x')
errorbar(25,2.0,1.9,16.5,'x')
errorbar(10,2.0,1.9,16.5,'x')
errorbar(30,2.0,1.9,16.5,'x')
errorbar(5,2.0,1.9,16.5,'x')
errorbar(20,2.0,1.9,16.5,'x')
The weirdness is that the whisker length appears to be dependent on my X value. As you can see it increases from left to right, even though I did not plot them from left to right. The single-sided width of each whisker is 0.01*x.
Why is this happening, and how can I fix it? This doesn't seem like intended functionality. Ideally I would just manually set the width of each whisker, but I can't find a way to do that. There was a function posted on the MFX a while back, but that was made for R2007b and no longer works. The errorbar series properties do not give any indication that the whiskers can even be affected at all. Any help here would be greatly appreciated!

MATLAB plot: strange horizontal lines

I am trying to produce a plot of theta vs. omega (theta on the x-axis, omega on the y-axis) and the plot I am generating looks ok except for stray horizontal lines that seem to span from -pi to pi. Does anyone know what causes this to happen, or how to remove them?
Thanks
Unless you provide your code, we won't be able to provide the good answer. These methods might help, though:
If there are sufficient points on the plot, and they are dense in the plot and less dense on the unwanted lines, you can try to insert 'bx' into plot, so the graph would consist of only blue crosses that would possibly make lines invisible retaining the remaining graph.
You can convert all the unwanted points in the matrices to NaN either manually or by adding some command like A(A>2)=NaN.

Is there a way to plot axis values with different (alternating) heights?

I like to plot in MATLAB a fourier-transformated signal.
Via set(gca,'xtick',peaks,'FontSize',12); i can show the peak values at the x-axis.
But sometimes, the peaks are too close together and the text showing the peak values is merging together with its neighbours. I have searched the web, but maybe asked the wrong question :)
So my question is:
How can i plot the peaks with alternating heights, like shown in the picture below?
I prefer the use of 1 x-axis.
Thank you for your help! :)
+1 for the interesting question.
Here's a way to do that, maybe not the most elegant, but shows the logic and make it happen:
x=0:pi/10:pi;
plot(x,sin(x));
set(gca, 'XTick', x, 'XTickLabel', cell(numel(x),1));
yl=get(gca,'YLim');
for n=1:numel(x)
if mod(n,2)
text(x(n), yl(1), {num2str(x(n)),''},'HorizontalAlignment','Center','VerticalAlignment','Top');
else
text(x(n), yl(1), {'',num2str(x(n))},'HorizontalAlignment','Center','VerticalAlignment','Top');
end
end
Use various text properties to change the font size, or text format etc...

How to change the format of the numbers displayed on an axis in a MATLAB plot?

I actually have 3 questions:
I have a plot with data that is in the thousands and my plot's axis is diplaying the tick marks as .4 .8 1.0 1.2 and a *10^4 in the lower right. This is a little annoying.
Besides dividing my data by 1000 or hardcodig the tick marks is there a way to change to tick marks from .4*10^4 TO 4000?
Seems like this should be trivial but aftter browsing through all of the figure's properties I can't seem to get an where.
And...once I get 4000 to apear instead of .4*10^4 is there a way to rotate the tick mark label so it is not overlapping the other labels.
And..how do you set how many "major" tick marks there are?
Thanks so much!
ME
Try the following:
x=[4000, 8000, 10000, 12000]; % define the x values where you want to have a tick
set(gca,'XTick',x); % Apply the ticks to the current axes
set(gca,'XTickLabel', arrayfun(#(v) sprintf('%d',v), x, 'UniformOutput', false) ); % Define the tick labels based on the user-defined format
Reference: Mathworks
In regards to the label rotation, it seems that Matlab does not support such feature by its own, but someone wrote a script for the label rotation, and you might want to give it a try.
There's a nice function by Yair Altman called ticklabelformat to do that in case you want to still be able to freely play with the axes afterwards
description:
http://undocumentedmatlab.com/blog/setting-axes-tick-labels-format/
and the download link:
http://www.mathworks.com/matlabcentral/fileexchange/36254-ticklabelformat-set-a-dynamic-format-of-axes-tick-labels