14

On my system, Mathematica 10.1.0 under Windows, none of these FrameTicks documentation examples work correctly:

(* Draw frame ticks at the specified positions with the specific labels: *)

Plot[Sin[x], {x, 0, 10}, Frame -> True, 
 FrameTicks -> {{{0, 0 °}, {Pi, 180 °}, {2 Pi, 360 °}, {3 Pi, 
     540 °}}, {-1/2, 1/2}}]


(* Specify frame ticks with scaled lengths: *)

Plot[Cos[x], {x, 0, 10}, Frame -> True, 
 FrameTicks -> {{{Pi, 180 °, {.4, .05}, Red}, {2 Pi, 360 °, {.4, .05}, 
     Thick}, {3 Pi, 540 °, {.4, .05}, Directive[Red, Dashed]}}, {-1, 1}}]


(* Specify frame ticks with scaled lengths in positive and negative directions: *)

Plot[Cos[x], {x, 0, 10}, Frame -> True, 
 FrameTicks -> {{{0, 0 °, {.4, .05}}, {Pi, 180 °, {.4, .05}}, {2 Pi, 
     360 °, {.4, .05}}, {3 Pi, 540 °, {.4, 0.05}}}, {-1/2, 1/2}}]


(* Specify the style of each frame tick: *)

Plot[Cos[x], {x, 0, 10}, Frame -> True, 
 FrameTicks -> {{{Pi, 180 °, {.4, .05}, Red}, {2 Pi, 360 °, {.4, .05}, 
     Thick}, {3 Pi, 540 °, {.4, .05}, Directive[Red, Dashed]}}, {-1, 1}}]

All produce a pink error box with a Tooltip message

enter image description here

Is this indeed a bug or have a broken something in my configuration?

Does it affect other versions and platforms or only 10.1.0 under Windows?


Related:

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • 2
    All broken on 10.1 on Mac Mavericks. All working on Win 7 on 10.0.2 – Gordon Coale Jun 23 '15 at 09:28
  • @Gordon Thanks. I guess it really is a bug then. – Mr.Wizard Jun 23 '15 at 09:28
  • Yep see it on 10.1, Ubuntu 12.04 – dr.blochwave Jun 23 '15 at 09:54
  • Same here for my Win 7/V10.1. Was working on V9. – Sjoerd C. de Vries Jun 23 '15 at 10:40
  • 1
    None of these are a problem for me using Linux v10.0.0 – JeffDror Jun 23 '15 at 12:16
  • Something is going wrong, when there are two y-axis ticks. – Karsten7 Jun 23 '15 at 14:19
  • 2
    Not a bug, but a deprecated form of the tick specification. – rcollyer Jun 23 '15 at 14:59
  • 1
    I would say that rcollyer has provided a convincing argumentation -- somtimes "things change" and we simple humans have to adapt and break with dear habits. ;-) In any case I would suggest to remove the bug tag because Mathematica does behave according to its current documentation. – gwr Jun 23 '15 at 17:19
  • 2
    Now the question is, which part of the documentation is incorrect? Are the examples outdated or is the list of possible setting incomplete? – Karsten7 Jun 23 '15 at 19:23
  • Now {bottomAndTop, leftAndRight} does work, except for the cases where at least one of them has two ticks. – Karsten7 Jun 23 '15 at 19:28
  • @Karsten7. which examples are you referring to? Links please. Also, oddly, you are correct, {bottomAndTop, leftAndRight} does work, if neither has two ticks specified. There it interferes with the documented form, so blows up. – rcollyer Jun 23 '15 at 19:39
  • @rcollyer I'm referring to the same examples of the documentation that Mr.Wizard copied into this question. It is the last one under Scope►FrameTicks Positions and Labeling and the first three examples under Scope►FrameTicks Styling. (Just open the FameTicks documentation and evaluate that notebook or use the link you provided in your answer, where btw you'll see that your solution doesn't match the output shown for that specific example, as there should be ticks on all sides.) – Karsten7 Jun 23 '15 at 19:53
  • @Karsten7. I really should have seen that link. :P – rcollyer Jun 23 '15 at 20:07
  • Now, I've reported the issue with the docs. – rcollyer Jun 23 '15 at 20:13
  • @rcollyer Thanks for the comment. Bugs tag removed, documentation tag added. – Mr.Wizard Jun 23 '15 at 22:46
  • @rcollyer Perhaps you would care to answer this related question which I have now linked in the question above? – Mr.Wizard Jun 23 '15 at 22:52

2 Answers2

20

This is not a bug, the tick specification used in the documentation is incorrect. The tick specification in these examples is

{bottom, left}

which is the short form of

{bottom, left, top, right}

which was an older tick specification that was deprecated in v7 (according to the docs). But, it was allowed to continue to work until v10. The form you are looking for is

{{left, right}, {bottom, top}}

or

{{{-1/2, 1/2}, None}, {{{0, 0 °}, {Pi, 180 °}, {2 Pi, 360 °}, {3 Pi, 540 °}}, None}}

which works just fine.

enter image description here

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
rcollyer
  • 33,976
  • 7
  • 92
  • 191
5

I can confirm this bug under Win 7 Mathematica 10.1.0.0.

A workaround for the moment is to specify all FrameTicks, e.g.

Plot[Sin[x], {x, 0, 10}, Frame -> True, 
 FrameTicks -> {ConstantArray[{-1/2, 1/2}, 2], 
                {#, #} &@{{0, 0 °}, {Pi, 180 °}, {2 Pi, 360 °}, {3 Pi, 540 °}}}]

Plot


Three more workarounds that narrow down the problem

Plot[Sin[x], {x, 0, 10}, Frame -> True, 
 FrameTicks -> {{{0, 0}, {Pi, 180}, {2 Pi, 360}, {3 Pi, 540}}, {-1/2, {0, ""}, 1/2}}]

Plot[Sin[x], {x, 0, 10}, Frame -> True, 
     FrameTicks -> {{{0, 0}, {Pi, 180}, {2 Pi, 360}, {3 Pi, 540}}, {-1/2, 1/2, 1/2}}]


Plot[Sin[x], {x, 0, 10}, Frame -> True, 
 FrameTicks -> {{{0, 0}, {Pi, 180}, {2 Pi, 360}, {3 Pi, 540}}, {-1/2, 1/2}}] /. 
Visualization`Utilities`ScaleFrameTicks[l1_List, {xTicks_List, wrong_}] :> 
 Visualization`Utilities`ScaleFrameTicks[l1, {{{-(1/2), 1/2}, {-(1/2), 1/2}}, xTicks}]
Karsten7
  • 27,448
  • 5
  • 73
  • 134