14

I have a piece of code that works well, but when I put a semicolon after a plotting statement, the semicolon appears in red. What's the error?

rm -rf
  • 88,781
  • 21
  • 293
  • 472
Mika Ike
  • 3,241
  • 1
  • 23
  • 38
  • 2
    It's not about the Print, it's just that you prevent a Plot to be plotted, so it appears red. – Öskå May 01 '14 at 10:06
  • @oska OK, I believed that if a line is Plot, Print,.... or similar with an output semicolos is accepted and the result will be showed – Mika Ike May 01 '14 at 10:14
  • @oska Thank you but... should be semicolon of Print in RED too? – Mika Ike May 01 '14 at 10:17
  • 2
    It's all about Plot not being plotted I guess. With or without ;, Print is printed. Check this. – Öskå May 01 '14 at 10:22
  • @oska Thank you, Oska Very illustrative – Mika Ike May 01 '14 at 10:37
  • 3
    Your screenshot is really tiny and hard to read. – Yves Klett May 01 '14 at 10:56
  • @YvesKlett the actual screenshot is of a sensible size, but it gets resized to fit the narrow column allowed for the question. (IMO, in the era of ubiquitous widescreen displays, it looks silly to leave a huge white space either side of the site content and use only a third or a quarter of the screen area for anything useful, but I suppose there must be a reason for it.) – Oleksandr R. May 01 '14 at 11:14
  • 1
    @OleksandrR. in any case the displayed version is neigh unreadable unless magnified. Agreed on the ample whitespace though. – Yves Klett May 01 '14 at 11:25
  • 2
    @OleksandrR.: That reason is typography. Most typographers agree that somewhere around 45-75 characters per line is optimal for long passages. The web has spoiled us somewhat in that regard - we've now grown more accustomed to wider measures (and unserifed faces). For instance, StackExchange, on my system, renders at about 100 characters per line, which is really near the border of too wide a measure. – Reid May 01 '14 at 19:20
  • @Reid I don't doubt that what you're saying is correct. But there are many problems with that as an explanation--as you pointed out, the choice of a sans serif font for one. And there is obviously no attempt at tracking or kerning either. But the more pressing issues, I would say, are: StackExchange posts rarely contain long passages of text; and pictures are not text anyway, so restricting them to the space allowed for text seems to make little sense. So, while you might well be right, if this is really the explanation, it IMO has the air of cargo-cultism about it. – Oleksandr R. May 12 '14 at 01:48
  • @OleksandrR.: Well, I don't want to get in a protracted discussion about this, but an unserifed face was chosen because serif faces tend to look poor at low DPI (computer monitors), so I don't think that's a "problem" with the argument. As for tracking and kerning, those are problems with the host system's font rendering mostly - on my end, it looks pretty good (though not perfect). Last, on the SE sites I frequent, long passages are pretty frequent, actually; these comments are a simple example. – Reid May 12 '14 at 05:56

2 Answers2

25

A bit of historic background

Before Mathematica version 6 graphics were produced as a side-effect much as Print works now. In fact you can load this old system using:

<< Version5`Graphics`

Now you get this behavior:

enter image description here

Note that the output is - Graphics - and the plot itself is handled like Print. Since there was often little value in having - Graphics - output it was common to see plot statements terminated with a semicolon, which returns Null which is not written to the Notebook.

In version 6 syntax highlighting of that trailing semicolon was added to remind people that with it no output at all would be produced, since the Graphics object is no longer printed as a side-effect.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
16

It's not a syntax mistake. Consider it a suggestion, FrontEnd tells you: "maybe you want to plot it as it has no much sense now".

Of course it may have sense, it's just a suggestion.

If you take a closer look you will find that storing such Plot makes more sense for FE:

enter image description here

Kuba
  • 136,707
  • 13
  • 279
  • 740