How can I plot text using normalized units?

I have used the following commands:
subplot(2, 2, 1)
plot(y)
text('Units', 'Normalized', 'Position', [0.1, 0.1], 'text')
And get the following error message:
error using text
Too many non-property / value arguments.

 Accepted Answer

When you do not use the x, y, str triple, then you need to use the 'string' parameter name to designate the text to draw.
y = rand(1,20);
subplot(2, 2, 1)
plot(y)
text('Units', 'Normalized', 'Position', [0.1, 0.1], 'string', 'text to draw', )

10 Comments

Sir,
Thank you for your input. I have tried your suggestion and it worked.
I looked carefully in the Matlab documentation :
and there did not seem to be a mention of this requirement. I have been programming since the 1980's and find Matlab to be the worst programming language I have ever dealt with.
  • axis positional property is optional first
  • then you can optionally have x, y, string, or x, y, z, string
  • name/value pairs go after that
None of the syntaxes permit name/value pairs before positional properties
I can't swear that there are absolutely no exceptions in any of the 10000+ functions supplied by Mathworks, but the standard for Mathworks is that name/value pairs always occur last in the calling sequence.
I have been programming since the mid 70s. COBOL was far far worse. Yacc+Lex are a struggle to learn how to use properly. teco was powerful but hard to learn. The vi editor was (is) useful but few people get as far as programming jumps in it. Perl has some interesting parts, but is "write only": if you take a break from any one program it is difficult pick up again later. SNOBOL is pretty useless. Some of the assembly languages I used were frustrating. A surprising number of the Unix utilities turn out to be programming languages. The programming languages of some of the network routers and switches are traps.
There is rather a lot of poor programming languages around.
I am just venting my frustration at how matlab doesn't really do a good job of explaining how to do anything outside of the vanilla norm. I grew to like IDL and now I mostly program in python and am starting to get into Julia. I am firmly entrenched in emacs and I detest the matlab editor. I realize that you can ask matlab to use emacs as the editor but then I have been unable to set up breakpoints which can be very handy, so I typically just use the horrible matlab editor. Perl was terrible in part because I never knew the state of the program and also the syntax is horrible. I still like C a lot but some of the newer languages are definitely easier to do some things in than C ever was. Once again thanks for your quick and helpful response.
I programmed in IDL for several years. It was ok. Got a bit clumsy for larger systems. We had to call out to C for the more intensive computations.
I liked IDL because it was able to make publication grade plots and was extremely flexible as to things like plotting greek symbols and color bars. None of my recently used languages (matlab, python, R) are as good and easy to use(in my opinion;-). I first used Matlab in 1991(Version 1 or 2) and as I recall it was unable to save plots in any format that I ever used.
I think you might have forgotten the mess that was font tables in IDL http://www.idlcoyote.com/ps_tips/greeksym.php
Hah, I still have an 8.5x11 sheet of paper with the translation between code and greek letter/symbol. At the time I pretty much had it memorized. It was not too bad, at least it was entirely consistent and predictable.(or that is how I am happily remembering it).
My peak IDL usage was while RSI (Research Systems Incorporated) still owned it. It was about the time of the Visible Human Project, and there was very nice volume viewing going on. MATLAB's volume viewing feels much weaker.
I remember RSI. I started to use IDL in the mid 90's and liked the company. I had friends from Boulder who knew all of the people on staff. What kind of work do you do now?

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!