# Why SciDraw can not handle the StreamPlot?

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
plot = StreamPlot[grad, {x, 0, 1}, {y, 0, 1}]


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}}]


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

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.

FigGraphics[plot]


use

FigGraphics[
]


### 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
]


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[

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.