Matlab plot title won't show - matlab

Here is a very simple MWE :
figure
x = 1:10;
plot(x)
title('mytitle','interpreter','none')
And the result with no title showing :
I am under Windows 7, Matlab R2015a. I do want the interpreter to be set to 'none' because I will be working with titles containing consecutive underscores - which would fail in Latex. And when I open the figure properties dialog and double-click on the title, it appears and is editable. Once I unselect it though, it disappears again. Help...

The problem here was that Matlab's default font was Helvetica, which is not available on my computer. So make sure to use a font available on your computer, by using the FontName argument if needed.
You can also set the default text font (here Courier) through :
set(0,'defaultTextFontName','Courier')

Related

What fonts are actually available for MATLAB graphics text? [duplicate]

I have a Matlab program where I need to include a plane icon (Zapf Dingbats 40) in the plot. Everytime I run it, it falls back to a system font.
Is there anything that I am doing wrong? This is not the exact code, but illustrates the problem:
title(char(40),'fontname','ZapfDingbats','fontsize',50);
The resulting plot always displays ( instead of the Dingbats plane icon ✈.
I verified that the font is installed and I can type with it on Word.
I am using Matlab R2013b on Mac OSX 10.9.1.
EDIT: It prints correctly to a pdf, but does not display correctly.
You may use the 'Wingdings' font for that. The following code
text(0.5, 0.5, char(81), 'fontname', 'Wingdings', 'fontsize',50);
gives
The 'ZapfDingbats' font may not be in the /Library/Font folder (but 'Wingdings' is), even if listfonts tells you that the font is there. Actually, the listfonts
function adds some extra fonts to the list of the available fonts, and I don't get the rational of that.
% always add postscipt fonts to the system fonts list.
systemfonts = [fonts;
{
'AvantGarde';
'Bookman';
'Courier';
'Helvetica';
'Helvetica-Narrow';
'NewCenturySchoolBook';
'Palatino';
'Symbol';
'Times';
'ZapfChancery';
'ZapfDingbats';
}];

MATLAB: Background color of Text in GUI

I want to use GUI (or directly the Command Windows) in MATLAB, which displays text. The text contain a few highlighted parts (which are changed during runtime), like this:
Is there any way I can do something liek that with MATLAB?
For command window you could try cprintf.
For displaying in a GUI you can use html formatting - going down this route you may find str2html useful.

MATLAB: figure fonts

A command of the form xlabel('$<stuff>$','interpreter','latex'); will produce an axis label that is typeset by TeX using a font that is presumably ComputerModern. However, the axis tick labels (e.g., 0, 1, 2, ...) appear in the default font (Helvetica?). I would like to synchronize all the fonts in the figure (preferably to ComputerModern).
Toward that end, I presume that a command of the form set(0,'DefaultAxesFontName', '<fontname>') may be useful. However, I need to know the exact name or path of the font used by the MATLAB TeX interpreter. How can I retrieve a string value for the font name or a path pointing to the font file for the default figure font and the default TeX-interpreted font?
You could also plot the axis ticks with latex, look here:
http://alex.bikfalvi.com/research/latex_in_matlab_ticks/
Actually, your command was right to mget the default font (when NOT using latex):
get(0,'defaultaxesfontname')
But I didn't find any to get the default latex font. Perhaps it would be possible by using the internal java routines (to get some ideas, look at http://undocumentedmatlab.com/)
You can download the computer modern font, and install it on your local machine. For Mac, you'll need to download the OTF format (i'm not sure on windows machines).
Then, researt matlab, and you can use
set(0,'DefaultAexsFontName', 'CMU Serif')
to make things look like latex font.

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')

MATLAB: Change font size of command window

I would like to temporarily change the font size of the text in the command window of MATLAB. I am running an experiment in which I am standing at the other side of the lab, and need to occasionally read a number from the screen. I don't want all the MATLAB output to be jumbo size forever - just this one variable when it occasionally comes up. I expect there must be some code that increases font size? I know I can adjust for example font colour using the following code:
com.mathworks.services.Prefs.setColorPref('ColorsText',java.awt.Color.red);
com.mathworks.services.ColorPrefs.notifyColorListeners('ColorsText');
(The above changes the text in the command window to red). There must be similar code to set font size?
The ideal solution would be a parameter to add to the fprintf command, such that only the one bit of output is larger. However, I would accept a solution in which the entire output of the screen is made larger temporarily...
Any help appreciated.
What about displaying all output in a figure instead of the command line? You could place text-objects and define colors and font sizes.
One way is the following:
"File > Preferences > Fonts > Custom" and there set your font and size. But it's not accessible setting from the commandline itsel so you would have to set it manually and afterwards disable it.
Edit:
To pop out a figure and print out a certain variable is easy:
foo = 100;
figure
uid = uicontrol('Style', 'text','String', ['FOO = ' num2str(foo)], 'FontSize', 80, 'ForegroundColor', 'b', 'Units','normalized','Position', [0 0 1 1]);
you could also specify the position and size of the figure window itself, if you want to.
To close the figure later, just use:
delete(gcf);
If you want to update the value of it, just use something like
set(uid, 'String', 'New text')
HOME TAB -> ENVIRONMENT TAB -> Preferences -> Fonts