Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is there a way to force Plot and related functions to place the tick labels inside, rather than outside a frame? For example, consider,

Plot[Sin[x], {x, 0, 10}, Frame -> True]

When this line is executed, the tick labels are outside the bottom and left edges of the frame:

enter image description here

Is there an easy way to move them to the inside?

(Why place tick labels inside the frame, you ask? I would like to export plots to PDF in a specified absolute size, so that one major tick on the plot is exactly 1 cm on the printout. If the labels were not placed on the outside, padding the image, this could be easily done using ImageSize, as described here.)

share|improve this question
    
You can fix the size of the graphic and the plot area simultaneously using ImagePadding as well as ImageSize. But some organizations use this style for their graphs so it would be useful to replicate. –  Verbeia Mar 5 '12 at 19:33
    
Ted, do you mean something like the last graph in this question? –  Verbeia Mar 5 '12 at 20:11
    
Nevertheless it would be nice to know if tick labels could be placed inside the plot without too much hacking. –  Mike Honeychurch Mar 5 '12 at 22:32
    
@Verbeia, yes, the arrangement of the y-frame labels in last graph in the question you linked to is what I had in mind. –  Ted Pudlik Mar 6 '12 at 1:18
add comment

2 Answers 2

up vote 7 down vote accepted

You could do something like this:

Plot[Sin[x], {x, 0, 10}, Frame -> True,
 Epilog -> {Table[Text[i, {i, -1}, {0, -1}], {i, Range[0, 10, 2]}],
  Table[Text[NumberForm[i, {2, 1}], {0, i}, {-1, 0}], {i, Range[-1, 1, .5]}]},
 FrameTicksStyle -> (FontOpacity -> 0),
 ImagePadding -> {{1, 1}, {1, 1}}]

Mathematica graphics

share|improve this answer
    
Much more concise than I had thought possible: thank you! –  Ted Pudlik Mar 6 '12 at 1:20
add comment

I don't know of an easy way, but with the help of Epilog, Inset and Scaled (the latter using a combo of absolute coordinates and scaled offsets) it's quite doable:

Plot[Sin[x], {x, 0, 10}, Frame -> True, 
 FrameTicks -> {{None, {{-1, ""}, {0, ""}, {1, ""}}}, {{{0, ""}, {Pi, 
      ""}, {2 Pi, ""}, {3 Pi, ""}}, None}}, 
  Epilog ->
  {
   Inset[0, Scaled[{0, -0.45}, {0, 0}]],
   Inset[\[Pi], Scaled[{0, -0.45}, {\[Pi], 0}]],
   Inset[2 \[Pi], Scaled[{0, -0.45}, {2 \[Pi], 0}]],
   Inset[3 \[Pi], Scaled[{0, -0.45}, {3 \[Pi], 0}]],
   Inset[-1, Scaled[{0.95, 0}, {0, -0.99}]],
   Inset[0, Scaled[{0.95, 0}, {0, 0}]],
   Inset[1, Scaled[{0.95, 0}, {0, 0.99}]]
   },
 BaseStyle -> {FontFamily -> "Arial", FontSize -> 14}
]

Mathematica graphics

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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