9
$\begingroup$

Bug introduced in 10.0 and persisting through 11.0


This is some rather perplexing behaviour. If I try to specify labels for the axes of a 3D plot, sometimes they will go completely belly up:

Plot3D[
 x^2 - y^2
 , {x, -1, 1}, {y, -1, 1}
 , AxesLabel -> {"a", "b"}
]

Mathematica graphics

Note the axis labels have nothing to do with the specified ones. What is going on here?

$\endgroup$
6
  • $\begingroup$ @Szabolcs Is that a fact? Pretty neat. What's the nature of the fix? Does the code above now work? Does it print an error? Or is it just a docs fix? $\endgroup$ Commented Aug 9, 2016 at 14:54
  • $\begingroup$ I just noted that it is still not fixed in 11.0. No fix. $\endgroup$
    – Szabolcs
    Commented Aug 9, 2016 at 14:57
  • $\begingroup$ hah. I misread 'persisting' as 'fixed'. To be honest I'm not completely sure this crosses the line from 'unfriendly syntax' over into 'bug' territory, but it would be nice to at least have a warning printed when an option setting is incorrect and being ignored. $\endgroup$ Commented Aug 9, 2016 at 15:01
  • $\begingroup$ Yes, there should be a warning, plus it works in 9.0 ... $\endgroup$
    – Szabolcs
    Commented Aug 9, 2016 at 15:04
  • 1
    $\begingroup$ No ... ! Noone has time for that. I just checked a few random ones because I was curious. $\endgroup$
    – Szabolcs
    Commented Aug 9, 2016 at 15:52

1 Answer 1

12
$\begingroup$

This is a minor bug, acknowledged by WRI and present as of v10.4. The problem is that for Plot3D the required syntax for AxesLabel is a list with three entries instead of two. When given a two-member list as an argument, though, Plot3D silently interprets that as the AxesLabel→Automatic setting, and it labels the axes with the internal variables of the plot, without even issuing a warning about the wrong syntax.

This behaviour is rather unfortunate and rather difficult to catch (particularly if, say, the specified label were something like

AxesLabel -> {Style["x", FontSize->16], Style["y", FontSize->16]}

which will look like the formatting is not taking effect), but hopefully this waymarker will help some other lost soul in the future.

For the case at hand, though, entering

Plot3D[
 x^2 - y^2
 , {x, -1, 1}, {y, -1, 1}
 , AxesLabel -> {"a", "b", ""}
]

with an empty "" in the third position, will solve the problem.

$\endgroup$
2
  • 1
    $\begingroup$ FYI AxesLabel -> {"a", "b", Automatic} works too. $\endgroup$
    – Greg Hurst
    Commented Jun 10, 2016 at 14:17
  • $\begingroup$ Yeah, that will also do it. The pitfall is that you need to put something in there (even Null works), but this can be hard to detect if you've got big hulking expressions with lots of formatting, say, in the first two entries. $\endgroup$ Commented Jun 10, 2016 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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