6
$\begingroup$

This question is related to aligning MaTeX text and aligning in SciDraw. Following the solution in these questions, I can position and align MaTeX text in SciDraw with respect to a well defined point. The problem now is that the text is huge and distorted, i.e., it scales with the aspect ratio of the plot. Below, see my attempts to fix the distortion by setting the size of the graphics to the same size as the plot.

How can this be done properly, i.e., inserting the MaTeX graphics without scaling and distortion?

Quiet@Get["SciDraw`"]
<< "MaTeX`"
tlg2 = Graphics[
        Inset[MaTeX["x=1", Magnification -> .5],
               {5, 5}, {Left, Center}, {50, Automatic}],
        ImageSize -> {50, Automatic}, 
        PlotRange -> {{0, 50}, {0, 10}}];
Figure[
 FigurePanel[{
  FigGraphics@tlg2,
  FigLine[{{5, 0}, {5, 10}}], 
  FigLine[{{0, 5}, {50, 5}}]}, 
 XPlotRange -> {0, 50}, 
 YPlotRange -> {0, 10}]
]

enter image description here

$\endgroup$
5
+50
$\begingroup$

I do not know if this is the best way, but it appears to work well:

  • Use FigLabel, the object intended for label construction in SciDraw
  • Specify an offset for the label

The offset can be given as

FigLabel[Anchor[{x,y}, offset], "label"]

or as

FigLabel[{x,y}, "label", TextOffset -> offset]

The offset specification is similar to the third argument of Text (see under Details in the docs), and can take either a scaled coordinate pair running from -1..1 or a named specification such as Left.

Thus you could use

Figure[
 FigurePanel[{
   FigLabel[{5, 5}, MaTeX["x=1", FontSize -> 24], 
    TextOffset -> Left];
   FigLine[{{5, 0}, {5, 10}}], FigLine[{{0, 5}, {50, 5}}]
   },
  PlotRange -> {{0, 50}, {0, 10}}
  ]
 ]

enter image description here

Instead of Left we could have used {-1,0}. This means that the anchor point ({5,5} here) is at scaled position {-1,0} inside of the label.

To use the bottom left as the anchor, use {-1,-1}. Then we obtain this:

enter image description here

It looks like as if there were too much space left below the label. This empty space is, in fact, part of the label graphics, and is there to leave room for characters with descenders such as g or y. You can ask MaTeX to crop tightly around the label using ContentPadding -> False.

Figure[
 FigurePanel[{
   FigLabel[{5, 5}, 
    MaTeX["x=1", FontSize -> 24, ContentPadding -> False], 
    TextOffset -> {-1, -1}];
   FigLine[{{5, 0}, {5, 10}}], FigLine[{{0, 5}, {50, 5}}]
   },
  PlotRange -> {{0, 50}, {0, 10}}
  ]
 ]

enter image description here

$\endgroup$
  • $\begingroup$ Wow, thank you, this was really what I was looking for! $\endgroup$ – Felix Aug 4 '17 at 0:16

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.