Matlab text() in figure - FontSize property not working - matlab

I want to show some text in a plot and adjust the fontsize. In the matlab reference I found it should be something like this:
text(.025,0.6,descr,'FontSize',20);
However, if I do this the fontsize is still the default 10px. I do not get any errors. The following does work:
text(.025,0.6,descr,'Color','red');
And this gives me an error, for unkown property:
text(.025,0.6,descr,'Size',20);
Anyone knows what I am doing wrong? I work on Matlab R2014a on Linux Mint.

Related

Issue using Surf, X Y Z and C cannot be complex

I'm trying to add a title to my surface plot, but attempting to add any descriptive text to the plot results in the above error. I can plot the data just fine, but attempting to add the title throws the error. I've listed my code below and can't figure out why a simple text title causes problems. I'd appreciate any ideas. Thanks!
function LWMMSweepPlots(excel,cpb,rpb)
data=xlsread(excel);
[r,c]=size(data);
iterations=round(c./cpb);
for i=1:iterations;
power=data(1:rpb,cpb*(i-1)+1:cpb*(i-1)+cpb);
xone=data(rpb*4-3:rpb*4-3+(rpb-1),cpb*(i-1)+1:cpb*(i-1)+cpb);
yone=data(rpb*5-2:rpb*5-2+(rpb-1),cpb*(i-1)+1:cpb*(i-1)+cpb);
xtwo=data(rpb+2,cpb*(i-1)+1);
ytwo=data(rpb*2+3,cpb*(i-1)+1);
xtn=num2str(xtwo);ytn=num2str(ytwo);
mytitle=strcat('X2,Y2 Coordinates:',xtn,',',ytn);
figure;surf(xone,yone,power,title(mytitle))
end
end
That's not how you add a title. If you want to add a title you need to use title separately. They way that you are doing it, MATLAB is treating the output of title as the CData of the surface.
figure
surf(xone, yone, power)
title(mytitle)

Bad clarity using export_fig

I am using Export_fig to export figs from matlab, I am getting very good plots generally. But when i add some textboxs and arrows in the fig. the clarity is pathetic.
I use the -transparent property, which does not work either.
export_fig('path', '-pdf','-transparent')
Anyone knows what is happening here. Normally this works very good, only when the text is added it acts like this way. Not sure if it's a glitch in the code or if i am doing anything wrong.
Note: I added the text and arrows with insert option on the menu bar.
If you are not set on using Export_fig for other reasons, consider using MATLAB's built-in print function and increase the resolution with the -r attribute
print('path', '-dpdf', '-r300')
where 'path' is the desired 'path\filename.pdf', '-dpdf' sets the file type, and '-r300' sets the resolution to 300 dpi, also try '-r0' for screen resolution, or higher, till you get what you want.
I'm not sure what the '-transparent' argument is used for but there is probably an equivalent you can find in the documentation.
https://www.mathworks.com/help/matlab/ref/print.html

In MatLab, how to adjust the line width drawn by the function 'gplot'?

As the help document of Matlab saying, we can use gplot in such a form as
gplot(A,Coordinates,LineSpec)
But when I try to modify the linewidth of the line and use a code like
gplot(A,Coordinates,'linewidth',2)
an error occurred and the error information saying that Error using gplot:
Too many input arguments.
I was wondering if their is anything wrong with my code.
Building on the answer of PearsonArtPhoto, the lines can be modified if they are explicitly found using findall(gcf,'type','line').
This is a working example:
k = 1:30;
[B,XY] = bucky;
gplot(B(k,k),XY(k,:),'-*')
set(findall(gcf,'type','line'),'LineWidth',5)
axis square
which produces the following figure
You could always do it manually. Try doing this right after plotting your figure.
set(gco,'LineWidth',2)

Enableing Line Smoothing causes axes drawing errors

In Matlab 2011a I am plotting a line, and I use the parameter ("LineSmoothing", 1) to make the line look prettier, but it causes the Y and X axis to disappear.
Does someone know what is causing this, and more importantly, how it can be fixed?
I tried the opengl('OpenGLLineSmoothingBug',1) but it didn't change anything.
Thanks in advance!
The undocumented LineSmoothing property causes the figure to automatically switch to using the OpenGL renderer. And the bug you've shown in fact affects all OpenGL-rendererd figures (regardless of this property use).
Example: (tested on R2012a in WinXP)
plot(1:10,'o-'), box on
set(gcf, 'Renderer','opengl')
note how the top and right borders of the box disappear once you execute the second line.
There are some suggested workarounds.

matlab font weight is set to normal but appears bold

As the title says, it was working fine but now the numbers in the axes appear to be bold, I tried another computer with the same functions and axes appeared normal (set to normal and appeared normal!).
Here's how it looks like:
If I change it to light it would be ok but why I'm getting this?
It has nothing to do with the 'centre axes' function I'm using.
Edit: Not just the axes, titles and labels as well!
Edit2: Everything in MatLab that has a figure like box appears bold! However, when I export a figure it appears normal
Thanks
Perhaps you changed the default fonts. Windows uses Arial by default. Try the following:
set(0, 'defaulttextfontname', 'Arial')
set(0, 'defaultaxesfontname', 'Arial')