12
$\begingroup$

I find that the package SciDraw is suitable for preparing the figure in the thesis. When I use it to plot the line, it works well. For example

<< SciDraw`
Figure[FigurePanel[{FigGraphics[Plot[Sin[10 x],{x,0,1}]]},
  XPlotRange -> {0, 1},
  XTicks -> LinTicks[0, 1, 0.2, 2],
  YPlotRange -> {0, 1},
  YTicks -> LinTicks[0, 1, 0.2, 2],
  YExtendRange -> 0.04,
  FontFamily -> "Times New Roman",
  FontSize -> 14,
  XFrameLabel -> X,
  XTickTextNudge -> -5,
  YTickTextNudge -> {-5, 0},
  YFrameLabel -> Y
  ],
 CanvasUnits -> Centimeter,
 CanvasSize -> {10, 10},
 CanvasMargin -> {{1.5, 0.5}, {1.5, 0.5}}]

I also want to use it to produce the streamplot, but it doesn't work well: the background of the figure is in the same color, and no line can be identified. For example

<< SciDraw`
grad = -Grad[Sin[10 x] Cos[10 y], {x, y}];
plot = StreamPlot[grad, {x, 0, 1}, {y, 0, 1}]

Mathematica graphics

Figure[FigurePanel[{FigGraphics[plot]},
  XPlotRange -> {0, 1},
  XTicks -> LinTicks[0, 1, 0.2, 2],
  YPlotRange -> {0, 1},
  YTicks -> LinTicks[0, 1, 0.2, 2],
  YExtendRange -> 0.04,
  FontFamily -> "Times New Roman",
  FontSize -> 14,
  XFrameLabel -> X,
  XTickTextNudge -> -5,
  YTickTextNudge -> {-5, 0},
  YFrameLabel -> Y
  ],
 CanvasUnits -> Centimeter,
 CanvasSize -> {10, 10},
 CanvasMargin -> {{1.5, 0.5}, {1.5, 0.5}}]

Mathematica graphics

$\endgroup$
4
  • $\begingroup$ "It doesn't work well": what actually happens that is undesirable? Can you be more specific? $\endgroup$
    – MarcoB
    Commented Mar 1, 2017 at 13:16
  • $\begingroup$ @MarcoB Thanks for your comment. I have edited the question. $\endgroup$
    – Ice0cean
    Commented Mar 1, 2017 at 13:22
  • 2
    $\begingroup$ @Ice0cean "A picture is worth a thousand words" $\endgroup$
    – Szabolcs
    Commented Mar 1, 2017 at 13:24
  • $\begingroup$ @Szabolcs Indeed it is. Also thanks for your detained interpretation. $\endgroup$
    – Ice0cean
    Commented Mar 1, 2017 at 13:33

1 Answer 1

15
$\begingroup$

In short, this is due to a behaviour in Mathematica's graphics rendering that seems intentional, but it is very strange in this particular context: Scaled coordinates are scaled by GeometricTransform and by Scale. The arrowheads sizes are specified in scaled coordinates. Unfortunately there is no good way to specify them in absolute (offset) coordinates.

SciDraw adds a GeometricTransform, which then affects the arrowheads, and (unintentionally) upscales them to ridiculous sizes. They become so large that they fill up the viewport.

Workaround

To work around the problem, I suggest manually reducing the arrowhead sizes to compensate. You can do this with replacement rules.

Instead of

FigGraphics[plot]

use

FigGraphics[
 plot /. Arrowheads[{{s_, pos_}}] :> Arrowheads[{{0.006 s, pos}}]
]

The underlying problem

The below graphics display the same way regardless the value of s. Also, all graphics elements scale proportionally when resizing the figure with the mouse. This is proof that the Arrowhead specification is in scaled coordinates.

s = 5;
Graphics[
 {Arrowheads[{{0.5, 1}}], Arrow[{{0, 0}, s {1, 0}}]},
 PlotRange -> s {{0, 1}, {-.25, .25}},
 AspectRatio -> Automatic,
 Frame -> True
]

Mathematica graphics

Now let us put in a GeometricTransform to scale everything to double size. To show the whole arrow, we manually double the plot range as well.

s = 5;
Graphics[
 {Arrowheads[{{0.5, 1}}], 
  GeometricTransformation[
   Arrow[{{0, 0}, s {1, 0}}], {2 {1, 0}, {0, 1}}]},
 PlotRange -> 2 s {{0, 1}, {-.25, .25}},
 AspectRatio -> Automatic,
 Frame -> True
 ]

Mathematica graphics

The scaling has affected the arrowhead. In this particular context this makes no sense to me. But the general behaviour is clearly intentional. The documentation of Scale explicitly states it:

For objects specified with scaled coordinates Scaled[{x,y}], Scale effectively applies its transformation to the corresponding ordinary coordinates.

Thus this is perhaps not a "bug" (even though in situations like this one it is clearly undesirable).

$\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.