3
$\begingroup$

I am working in Mathematica 11.0.1.0 for Mac. This is taken directly from the Mathematica documentation for ListLinePlot

{m1, m2, m3, m4} = Graphics /@ {Circle[{0, 0}, 1], Disk[{0, 0}, 1], Line[{{-0.5, -0.5}, {0.5, -0.5}, {0.5, 0.5}, {-0.5, 0.5}, {-0.5, -0.5}}], Polygon[{{-0.5, -0.5}, {0.5, -0.5}, {0.5, 0.5}, {-0.5, 0.5}}]}

ListLinePlot[Table[n^(1/p), {p, 4}, {n, 10}], PlotMarkers -> Table[{s, 0.05}, {s, {m1, m2, m3, m4}}]]

and makes the plot:

enter image description here

Next I tried to put the plot in a "Figure Panel" in SciDraw:

Figure[
 FigurePanel[{
   FigGraphics[
    ListLinePlot[Table[n^(1/p), {p, 4}, {n, 10}], 
     PlotMarkers -> 
      Table[{s, 0.05}, {s, {m1, m2, m3, m4}}]]]}, 
  XPlotRange -> {0, 10}, XFrameLabel -> "x", YPlotRange -> {1, 6}], 
 CanvasSize -> {5, 5}]

It made an all black figure (not shown). Changing s from 0.05 to 0.005, gives:

enter image description here

Trying to shrink s further yields:

enter image description here

Clearly, PlotMarkers does not scale properly in SciDraw. My questions are

  1. Why not?
  2. How can I get the proper figure to appear in a SciDraw Figure Panel?

Ultimately the goal is to have a multipanel figure made in SciDraw with my own data and custom (properly scaled!) plot markers.

$\endgroup$

1 Answer 1

1
$\begingroup$

I ran into a similar issue recently, and while I don't have the Mathematica knowledge to fully explain the details of the issue which is happening here, I think I know enough to answer both of your questions. This is for everyone who comes after, as this is surely something that you're no longer worried about for this plot.

  1. PlotMarkers do not scale properly in this instance because the plot marker is a Graphics object, and SciDraw uses GeometricTransform to take the originally generated plot and convert it to the SciDraw plot. Specifically, it appears the issue arises because of a mismatch between the PlotRange and CanvasSize. By using a Graphics object for the plot marker, you're effectively tying a given location on the marker to a fixed point on the plot. If you match the CanvasSize with the PlotRange the markers are at least no longer distorted, but you'll still run into issues if you try to make the markers "too small"

     Figure[FigurePanel[{FigGraphics[
     ListLinePlot[Table[n^(1/p), {p, 4}, {n, 10}], 
     PlotMarkers -> Table[{s, 0.007}, {s, {m1, m2, m3, m4}}]]]}, 
     XPlotRange -> {0, 10}, YPlotRange -> {0, 10}], XFrameLabel -> "x", 
     CanvasSize -> {6, 6}]
    

    Gives

    enter image description here

    Somehow, SciDraw doesn't appropriately translate the GeometricTransform for the PlotMarkers. Again, I wish I could tell you the details of why this happens, but it's beyond me. See this post and this one for some additional background. Somehow, you need to prevent the PlotMarkers from being transformed by SciDraw. As I learned from the next part of the answer, you can do this with your own custom built Graphics objects by using Offset in the construction of the Graphics objects. The downside to this is that your plot marker size is now fixed, so if you increase the size of your plot, your markers will now look tiny.

  2. How to get the proper figure? Though I don't recommend it, you can use Offset with your graphics to make a graphics object which is fixed in size and won't be modified by GeometricTransform.

     scale = 5;
     {m1, m2, m3, m4} = 
      Map[Graphics[#] &, {Circle[{0, 0}, Offset[scale]], 
        Disk[{0, 0}, Offset[scale]], 
        Line[Offset /@ {{-scale/2, -scale/2}, {scale/2, -scale/2},
     {scale/2, scale/2}, {-scale/2, scale/2}, {-scale/2, -scale/2}}], 
        Polygon[{Offset[{-scale/2, -scale/2}], Offset[{scale/2, -scale/2}],
           Offset[{scale/2, scale/2}], Offset[{-scale/2, scale/2}]}]}]
    
     ListLinePlot[Table[n^(1/p), {p, 4}, {n, 10}], 
      PlotMarkers -> {m1, m2, m3, m4}]
    
     Figure[FigurePanel[{FigGraphics[
         ListLinePlot[Table[n^(1/p), {p, 4}, {n, 10}], 
          PlotMarkers -> {m1, m2, m3, m4}]]}, XPlotRange -> {0, 5}, 
       YPlotRange -> {0, 10}], XFrameLabel -> "x", CanvasSize -> {10, 6}]
    

    Gives

    enter image description here

    The downside to this method is that you can't use Scaled on the plot markers in the plotting function, you'll run into the same clipping issues you saw before. This isn't too bad though, since you can make a function which constructs your markers and specifies their size.

    You might have noticed that the markers in the previous plot didn't seem to be the right sizes. If you're using fairly standard markers (circles, squares, triangles) for you plot, I would recommend that you use the excellent package PolygonPlotMarkers. The author of this package put a lot of thought into what makes the markers "publication quality" including making sure that the markers have the same filled area when printed. Again, when making the plot markers, you must specify them in "absolute" (Offset) coordinates. If you don't, you'll get the same weird scaling effects you've seen before. Here's some code that reproduces your plot with PolygonPlotMarkers

     size = Offset[10];
     markers = Map[Graphics[#] &, {
          {FaceForm[], EdgeForm[{AbsoluteThickness[1], JoinForm["Miter"]}], 
            ResourceFunction["PolygonMarker"]["Circle", size]}
        , ResourceFunction["PolygonMarker"]["Circle", size]
        , {FaceForm[], EdgeForm[{AbsoluteThickness[1],
            JoinForm["Miter"]}],
            ResourceFunction["PolygonMarker"]["Square", size]}
        , ResourceFunction["PolygonMarker"]["Square", size]
        }]
    
     ListLinePlot[Table[n^(1/p), {p, 4}, {n, 10}], PlotMarkers -> markers]
    
     Figure[FigurePanel[{FigGraphics[
         ListLinePlot[Table[n^(1/p), {p, 4}, {n, 10}], 
          PlotMarkers -> markers]]}, XPlotRange -> {0, 10}, 
       YPlotRange -> {0, 6}], XFrameLabel -> "x", CanvasSize -> {5, 5}]
    

enter image description here

Note that now the markers appear to be roughly the same size, and you don't have to hassle with changing your custom graphics.

$\endgroup$

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.