2
$\begingroup$

So i have the following codes:

Graphics3D[{
  Sphere[{0, 0, 0}, 0.5]
  }, Axes -> False, Boxed -> True, BoxRatios -> {1, 1, 1/5}, 
 BoxStyle -> Directive[Gray, Dashed, Thick], 
 PlotRange -> {{-20, 20}, {0, 40}, {-4, 4}}, ImageSize -> {900, 600},
 Epilog -> Inset[
   Text[Style["Title", FontSize -> 40, 
     FontFamily -> "Lucida Calligraphy"]], {Left, Top}, {Left, Top}]
 ]

the output is:enter image description here

The "title" is not placed at the top left corner on the image, i want it to be at the corner of the orange box, pls help.

$\endgroup$
1
  • 4
    $\begingroup$ Try something like Labeled[(* stuff *), Style["Title", FontSize -> 40, FontFamily -> "Lucida Calligraphy"], {{Top, Left}}] $\endgroup$ Jan 30, 2021 at 11:10

2 Answers 2

1
$\begingroup$

I'm posting J.M.'s comment as an answer:

Labeled[
 Graphics3D[{Sphere[{0, 0, 0}, 0.5]}, Axes -> False, Boxed -> True, 
  BoxRatios -> {1, 1, 1/5}, 
  BoxStyle -> Directive[Gray, Dashed, Thick], 
  PlotRange -> {{-20, 20}, {0, 40}, {-4, 4}}, ImageSize -> {900, 600}
  ],
 Style["Title", FontSize -> 40, FontFamily -> "Lucida Calligraphy"],
 {{Top, Left}}
 ]

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ thanks, but would you pls explain why Labeled[] works, but inset[] doesn't? when i used inset[], the tile constantly adjusts its position, why does that happen? $\endgroup$
    – DORA
    Feb 9, 2021 at 10:28
  • $\begingroup$ @DORA I think it's because you need to set the PlotRange explicitly. $\endgroup$
    – C. E.
    Mar 14, 2021 at 16:17
1
$\begingroup$

You can use Panel[obj, title] which, by default, places title on the top left:

label = Style["Title", FontSize -> 40, FontFamily -> "Lucida Calligraphy"];

graphics = Graphics3D[{Sphere[{0, 0, 0}, 0.5]}, Axes -> False, Boxed -> True, 
   BoxRatios -> {1, 1, 1/5}, 
   BoxStyle -> Directive[Gray, Dashed, Thick], 
   PlotRange -> {{-20, 20}, {0, 40}, {-4, 4}}, 
   ImageSize -> {500, 400}];

Panel[graphics, label]

enter image description here

You can remove the frame using the option Appearance -> "Frameless":

Panel[graphics, label, Appearance -> "Frameless", Background -> White]

enter image description here

We get the same picture using

Panel[graphics, "Title",
 Appearance -> "Frameless", Background -> White, 
 LabelStyle -> {FontSize -> 40, FontFamily -> "Lucida Calligraphy"}]
$\endgroup$

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.