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.

 採用された回答

Walter Roberson
Walter Roberson 2022 年 2 月 24 日

0 投票

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 件のコメント

John Williams
John Williams 2022 年 2 月 24 日
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.
Walter Roberson
Walter Roberson 2022 年 2 月 24 日
  • 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.
Walter Roberson
Walter Roberson 2022 年 2 月 25 日
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.
John Williams
John Williams 2022 年 2 月 25 日
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.
Walter Roberson
Walter Roberson 2022 年 2 月 25 日
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.
John Williams
John Williams 2022 年 2 月 25 日
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.
Walter Roberson
Walter Roberson 2022 年 2 月 25 日
I think you might have forgotten the mess that was font tables in IDL http://www.idlcoyote.com/ps_tips/greeksym.php
John Williams
John Williams 2022 年 2 月 25 日
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).
Walter Roberson
Walter Roberson 2022 年 2 月 27 日
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.
John Williams
John Williams 2022 年 2 月 28 日
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?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeText Data Preparation についてさらに検索

製品

リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by