6
$\begingroup$

In version 10.0.1 (Win7), AxesLabel with arbitrary text strings works as expected in 2D plots:

Plot[Sin[x], {x, -4, 4}, 
 AxesLabel -> {"Range (km)", "Velocity (m/sec)"}]

enter image description here

In prior versions the same worked for 3D plots as well; but not anymore in v. 10:

Plot3D[Sin[x - 3 y], {x, -3, 3}, {y, -3, 3}, 
 AxesLabel -> {"Range (km)", "Velocity (m/sec)"}, 
 LabelStyle -> Directive[Blue, Large]]

enter image description here

Is this a bug? And is there a workaround?

Thanks

$\endgroup$
  • 1
    $\begingroup$ You can add a third dummy element in AxesLabel (e.g. {"Range (km)", "Velocity (m/sec)", ""}). I think it is a small bug. $\endgroup$ – ybeltukov Oct 12 '14 at 19:23
  • $\begingroup$ @ybeltukov Thank you; didn't think of trying that! $\endgroup$ – ulvi Oct 12 '14 at 19:36
6
$\begingroup$

Let me expand my comment. As I wrote, you can write

AxesLabel -> {"Range (km)", "Velocity (m/sec)", ""}

One label also works fine

AxesLabel -> {"Range (km)"}

But two labels doesn't work

AxesLabel -> {"Range (km)", "Velocity (m/sec)"}

Unfortunately it is equivalent to AxesLabel -> Automatic. The problem is in the definition of Visualization`Utilities`AxesLabelQ

Visualization`Utilities`AxesLabelQ[#, 3] & /@ {{"x"}, {"x", "y"}, {"x", "y", "z"}}

{True, False, True}

You can repair it by the following command

Unprotect[Visualization`Utilities`AxesLabelQ];
Visualization`Utilities`AxesLabelQ[{_?
     Visualization`Utilities`OptionsDump`axislabelTokenQ, _?
     Visualization`Utilities`OptionsDump`axislabelTokenQ}, 
   Visualization`Utilities`OptionsDump`n_: 3] /; 
  Visualization`Utilities`OptionsDump`n === 3 := True
Protect[Visualization`Utilities`AxesLabelQ];

Now everything works as desired

Plot3D[Sin[x - 3 y], {x, -3, 3}, {y, -3, 3}, 
 AxesLabel -> {"Range (km)", "Velocity (m/sec)"}]

enter image description here

$\endgroup$
  • $\begingroup$ Just curious as to what you used to find this function? $\endgroup$ – rcollyer Oct 13 '14 at 12:37
  • $\begingroup$ @rcollyer just ?? and ClearAttributes[..., ReadProtected] for Plot3D and some nested functions. $\endgroup$ – ybeltukov Oct 13 '14 at 12:40
1
$\begingroup$

There are bugs within bugs. Consider this sequence:

V9

$Version

"9.0 for Microsoft Windows (64-bit) (January 25, 2013)"

Plot3D[Sin[x - 3 y], {x, -3, 3}, {y, -3, 3},
 ImageSize -> 500,
 AxesLabel -> {"Range (km)", "Velocity (m/sec)"},
 LabelStyle -> Directive[Blue, Large]]

enter image description here

Plot3D[Sin[x - 3 y], {x, -3, 3}, {y, -3, 3},
 ImageSize -> 500,
 AxesLabel -> {"Range (km)", "Velocity (m/sec)", Automatic},
 LabelStyle -> Directive[Blue, Large]]

enter image description here

V10

$Version

"10.0 for Microsoft Windows (64-bit) (June 29, 2014)"

Plot3D[Sin[x - 3 y], {x, -3, 3}, {y, -3, 3},
 AxesLabel -> {"Range (km)", "Velocity (m/sec)"},
 LabelStyle -> Directive[Blue, Large],
 PlotTheme -> "Classic",
 ImageSize -> 500]

enter image description here

Plot3D[Sin[x - 3 y], {x, -3, 3}, {y, -3, 3},
 AxesLabel -> {"Range (km)", "Velocity (m/sec)", Automatic},
 LabelStyle -> Directive[Blue, Large],
 PlotTheme -> "Classic",
 ImageSize -> 500]

enter image description here

Well, I accept and welcome that V10 requires the third Automatic - parameter. I am, however, hesitant to accept that blue turns to black and that classic isn't classic anymore.

$\endgroup$

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.