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.

I am creating some plots that use FrameStyle->AbsoluteThickness@5 and PlotStyle->AbsoluteThickness@0.5. In my plots' Epilog option, I want to use some Inset[Framed@...,FrameStyle->AbsoluteThickness@0.5] expressions. Upon exporting the graphics to PDF, I noticed that the FrameStyle option does nothing. This lead me to the following question on this site:

Formatting Framed - Some FrameStyle graphics directives don't work

So I tried the following, to get a feeling for what BoxFrame does:

Plot[Sin[x], {x, 0, 2 Pi},
 PlotStyle -> AbsoluteThickness@0.5,
 Frame -> True,
 FrameStyle -> AbsoluteThickness@0.5,
 ImageSize -> 180,
 Epilog -> {Inset[
    Framed["sin(x)", BoxFrame -> {{0.1, 0.5}, {5, 0}}],
    {3/2 Pi, 0.5}]}]

The resulting PDF looks like this:

enter image description here

It seems like only integer numbers work in the BoxFrame option. But how can I make the frame thinner? Especially, how can I make it exactly 0.5 pt thick?

share|improve this question
    
I used to make nested Framed objects to take control. –  Kuba Jun 21 '13 at 11:56
    
Could you provide an example of that? –  einbandi Jun 21 '13 at 12:05
add comment

2 Answers

up vote 1 down vote accepted

Another possible way would be using an inline Cell with specified CellFrame.

labelcell =
    Cell[BoxData[
                 ToBoxes[
                        Style[ Defer[Sin[x]],
                               20, GrayLevel[.4], FontFamily -> "Constantia"],
                        TraditionalForm]
                ],
         CellFrame -> {{1, 4}, {6, 10}},
         CellFrameMargins -> 5,
         CellFrameColor -> RGBColor[0.2, 0.4, 0.7]
        ] // Cell[TextData[{#}]] &; (* make it an inline Cell *)

Plot[Sin[x], {x, 0, 2 Pi},
     PlotStyle -> AbsoluteThickness@0.5,
     Frame -> True,
     FrameStyle -> AbsoluteThickness@0.5,
     ImageSize -> 500,
     Epilog -> {
                Inset[RawBoxes[labelcell], {3/2 Pi, 0.5}]
               }
    ]

CellFramed label

share|improve this answer
    
Thanks! With your solution I finally get the desired output, even in the PDF. It's a shame that there seems to be no simple way for such a simple problem... –  einbandi Jun 25 '13 at 21:25
    
@einbandi Thanks for acceptance! I don't know why Framed doesn't work.. Fortunately there are always more than one roads lead to Rome. :D –  Silvia Jun 25 '13 at 21:30
add comment

I hate situations when MMA is forcing me to create such inelegant solutions. It is how I am dealing with it:

The basic idea is to govern the margins by outerFrame FrameMargins. One good thing here is FrameMargins:

specifies the absolute margins in printer's points to leave inside the frame

With[{
  outerFrame = Sequence[Alignment -> Center, Background -> Black, 
                        FrameMargins -> {{25, 5}, {10, -1}}],
  innerFrame = Sequence[Background -> White, FrameStyle -> None, ImageMargins -> 0]
   },
 Plot[
  Sin[x], {x, 0, 2 Pi},
  PlotStyle -> AbsoluteThickness@0.5, Frame -> True, FrameStyle -> AbsoluteThickness@0.5, 
  ImageSize -> 480, Epilog -> {
    Inset[
     Framed[Framed["sin(x)", innerFrame], outerFrame]
     , {3/2 Pi, 0.5}]}]
  ]

enter image description here

share|improve this answer
    
I like the idea of this answer, but I just can't get it to work properly. The thinnest frame I can get is exactly as thick as the one using FrameStyle or BoxFrame (which looks like 1 pt in the resulting PDF). –  einbandi Jun 25 '13 at 21:18
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.