9

Is it possible to print some characters like 'ح' (U+062D) as the title of an image in a subplot?

Jalal
  • 6,594
  • 9
  • 63
  • 100

2 Answers2

9

Using some Java as described by Yair Altman on undocumentedmatlab.com, you can add HTML-aware labels to your plot. You can therefore put your Unicode character 'ح' (U+062D) into such a label using the &#xHEXCODE; syntax, in your case ح:

figure;
labelStr = '<html>&#x062D;</html>';
jLabel = javaObjectEDT('javax.swing.JLabel',labelStr);
[hcomponent,hcontainer] = javacomponent(jLabel,[100,100,40,20],gcf);

This should display an empty figure window which just contains that single Unicode character. Tested on Matlab R2010b with WinXP.

For more information about tricking MATLAB into displaying Unicode, see this SO post which might in parts be specific to OS X.

Note that a few characters which are not available in your current character set can be available through the native LaTex capabilities of MATLAB title() as discussed here; however this is far from covering all of Unicode.

Community
  • 1
  • 1
Jonas Heidelberg
  • 4,984
  • 1
  • 27
  • 41
-1

After looking at: Unicode characters in MATLAB source files

http://www.mathworks.com/help/techdoc/ref/unicode2native.html

http://www.mathworks.com/help/techdoc/ref/native2unicode.html

I think there is some hope that you may be able do print the unicode characters on the title of subplot.

good luck.

Community
  • 1
  • 1
A. K.
  • 34,395
  • 15
  • 52
  • 89
  • 1
    The SO post you link to contains the comments "I'm accepting this answer, even though the problem remains unsolved" and "As far as I can tell MATLAB has a serious allergy to Unicode.". The two functions you link to are about modifying the representation of unicode text in memory, not about display... – Jonas Heidelberg Aug 10 '11 at 18:26
  • the OP for that question was able to print the Unicode characters on the editor, but after restarting the matlab, strange characters appear. In your case once you get the output on the image you can save the image in jpg or other format then you don't have to worry about that i guess – A. K. Aug 10 '11 at 18:34
  • He was able to *type* unicode into the editor (so the edit control used for the MATLAB editor is able to deal with it); but once he saved the source file the symbol was replaced directly by a question mark. That question has *nothing* to do with figures or plotting, so it is quite useless for the question here, except to indicate that MATLAB isn't quite ready for Unicode. – Jonas Heidelberg Aug 10 '11 at 18:40