11
$\begingroup$

Bug introduced in 9.0 and persisting through 11.0.1 or later


Consider the following few examples, each producing a trivial graphic object:


Graphics[Circle[], PlotLabel -> "X", Frame -> True]

It is a circle in a frame, with a label, naturally works fine.


Graphics[Circle[], LabelStyle -> {FontSize -> 24}, Frame -> True, PlotLabel -> "X"]

All the same, but now we define the size of the labels. Works okay.


Now the problem, try defining FontSize through, e.g. FontSize->Large:

Graphics[Circle[], LabelStyle -> {FontSize -> Large}, Frame -> True, PlotLabel -> "X"]

This gives a complain "specified setting for FontSize" cannot be used.


I would guess, maybe the syntax for fonts has changed in V10, but the problem does not appear if no plotlabel is specified (i.e. the labels on the frame are displayed properly):

Graphics[Circle[], LabelStyle -> {FontSize -> Large}, Frame -> True]

This works okay.


What is more, even in documentation one examplifies using FontSize in a construction like this:

Table[Text[Style["ABC", FontSize -> p]], {p, {Tiny, Small, Medium, Large}}]

To summarize: It looks as if when construction LabelStyle -> {FontSize -> Large} goes together with PlotLabel->"Something", an error pops up.

Question: Can anyone reproduce it? (done, see comments to Lou's answer) Is it an intended behavior? If so, why?

I am using ubuntu 14.04, MMA 10.0.1

Edit: And yes, I have tried it on MMA 9.0, Windows 7, and the problem does not appear there.

Edit 2: Added a summary of the problem in a separate answer.

$\endgroup$
  • 2
    $\begingroup$ Note: LabelStyle -> {"Large"} works on both the frame and the PlotLabel. ("Large" is a style defined in core.nb. I'm not sure why Large without the quotes fails on PlotLabel. Bug, perhaps?) $\endgroup$ – Michael E2 Nov 6 '14 at 2:32
  • 1
    $\begingroup$ Strange, indeed. By the way Graphics[Circle[], LabelStyle -> Larger, Frame -> True, PlotLabel -> "X"] works (Larger instead of Large) $\endgroup$ – user18792 Nov 6 '14 at 6:36
  • 1
    $\begingroup$ Still there in 10.0.2 $\endgroup$ – Sjoerd C. de Vries Dec 11 '14 at 19:46
  • 1
    $\begingroup$ The style "Label" has the setting FontSize->"Small" defined in Core.nb and leads to the same error when "Label" is used as the LabelStyle in Graphics. (At least in V10.0.2.) It seems to be the only style in Core.nb that has FontSize defined this way. $\endgroup$ – Michael E2 Jan 23 '15 at 13:38
  • 2
    $\begingroup$ Still there in 11.0.1 as well. $\endgroup$ – M.R. Oct 16 '16 at 21:01
7
$\begingroup$

Some final remarks on this, concluding from nice communications with Wolfram support.

A command of this form is generally intended to work and to produce a label in large size:

Graphics[Disk[], LabelStyle -> {FontSize -> Large}, PlotLabel -> "X"]

It doesn't however, and it is a known bug since MMA version 9 (that is, at least in V9 and V10). In V10 it produces an error message, whereas in V9 it does not work as intended.

Some workarounds have been mentioned in comments and answers, here is a workaround summary:

  • Use FrameLabel instead of PlotLabel (credit to Lou). Though not identical, this might serve as a substitute
  • Use {FontSize -> 24} instead of {FontSize -> Large}, or analagously for other sizes
  • Use {FontSize -> "Large"} instead of {FontSize -> Large}. It happens to work because of default style definition for a style called "Large" (indeed in Core.nb), but it will not work generally, e.g. {FontSize -> "Tiny"} does not work.
  • Further examples of working commands might be found in the answer by Mr.Wizard

So much for it, and let's hope to see the bug fixed in the future versions.

$\endgroup$
3
$\begingroup$

Thanks for making us aware of this problem.

Momentarily exploring this myself I note that these also work:

LabelStyle -> {"Large"}

LabelStyle -> {"Tiny"}

LabelStyle -> {24}

LabelStyle -> Directive["Large"]

LabelStyle -> Directive["Tiny"]

LabelStyle -> Directive[24]

Hopefully this is useful information to someone encountering the problem.

$\endgroup$
  • $\begingroup$ Thanks a lot for your addition! I will refer to your answer in my summary post. $\endgroup$ – Alexey Bobrick Nov 10 '14 at 17:23
2
$\begingroup$

I can repeat the error with 10.0 for Mac OS X x86 (64-bit) (September 10, 2014), but 9.0 for Mac OS X x86 (64-bit) (January 24, 2013) does not seem to exhibit this behavior.

Frame labels are affected by LabelStyle, i.e., as a Workaround one can use:

Graphics[Circle[], Frame -> True, FrameLabel -> "X", LabelStyle -> Directive[Red, Large]]

works as expected.

enter image description here

Whether an error or a bug or a glitch, PlotLabel and FrameLabel as such must be distinguished carefully:

enter image description here

See also this Q/A.

$\endgroup$
  • $\begingroup$ @Alexey Bobrick, Yep, the same problem with 10.0 for Mac OS X x86 (64-bit) (September 10, 2014), I showed a workaround. With Directive you do not have an error message. $\endgroup$ – user9660 Nov 5 '14 at 20:25
  • $\begingroup$ Thanks for the interesting point! I guess, the thing is that it works okay with FrameLabel, but not with PlotLabel. Directive doesn't seem to help though with PlotLabels. $\endgroup$ – Alexey Bobrick Nov 5 '14 at 20:27
  • $\begingroup$ This way, there are two workarounds indeed: one is to use FrameLabel, another - to specify fontsize in absolute units. Still, I wonder, if it is an intended behavior. $\endgroup$ – Alexey Bobrick Nov 5 '14 at 20:29
  • $\begingroup$ though, maybe I could ask you to edit your answer a tiny bit, for it might mislead people into thinking that the problem is not present. $\endgroup$ – Alexey Bobrick Nov 5 '14 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.