1
$\begingroup$

It may be hard to describe so here I provide a minimal example.

What I did here is to first create a density plot and then put a color bar aside(like what built-in PlotLegend does).

The list density plot is:

testdat = Table[x^2 + y^2, {x, 0, 1, 0.01}, {y, 0, 1, 0.01}];
testfig = 
 ArrayPlot[Reverse@testdat, DataRange -> {{0, 1}, {0, 1}}, 
  PlotRangePadding -> None, ColorFunction -> "TemperatureMap"]

The figure I got:

enter image description here

Then the colorbar:

testbar = 
 DensityPlot[y, {x, 0, 1}, {y, 0, 1}, AspectRatio -> 15, 
  ColorFunction -> "TemperatureMap", PlotRangePadding -> None]

enter image description here

Combine them using Multipanel:

Figure[Multipanel[{FigurePanel[{FigGraphics[testfig]}, {1, 1}, 
    XPlotRange -> {0, 1}, YPlotRange -> {0, 1}, 
    XFrameLabel -> Subscript[textit["\[Alpha]"], 1], 
    XTicks -> LinTicks[0, 1, 0.5, 1], 
    YTicks -> LinTicks[0, 1, 0.5, 1], 
    YFrameLabel -> Subscript[textit["\[Alpha]"], 2], FontSize -> 20], 
   FigurePanel[{FigGraphics[testbar]}, {1, 2}, XTicks -> None, 
    YTicks -> None, YPlotRange -> {0, 1}, YYTicks -> LinTicks[0, 1], 
    ShowTickLabels -> {{True, True}, {True, True}}, 
    XXFrameLabel -> textit["I"], 
    ShowFrameLabel -> {{True, True}, {True, True}}, FontSize -> 20]}, 
  Dimensions -> {1, 2}, XPanelSizes -> {1, 0.05}, 
  ShowTickLabels -> True, XPanelGaps -> 0.05, PanelLetter -> None], 
 CanvasSize -> {3.4, 3.4}]

The output is:

enter image description here

You see the data region is strangely shifted to the x=[-0.5,0.5], y=[0.5,1.5]. To be clear, if we make the PlotRange larger:

Figure[Multipanel[{FigurePanel[{FigGraphics[testfig]}, {1, 1}, 
    XPlotRange -> {-1, 1}, YPlotRange -> {0, 2}, 
    XFrameLabel -> Subscript[textit["\[Alpha]"], 1], 
    XTicks -> LinTicks[-1, 1, 0.5, 1], 
    YTicks -> LinTicks[0, 2, 0.5, 1], 
    YFrameLabel -> Subscript[textit["\[Alpha]"], 2], FontSize -> 20], 
   FigurePanel[{FigGraphics[testbar]}, {1, 2}, XTicks -> None, 
    YTicks -> None, YPlotRange -> {0, 1}, YYTicks -> LinTicks[0, 1], 
    ShowTickLabels -> {{True, True}, {True, True}}, 
    XXFrameLabel -> textit["I"], 
    ShowFrameLabel -> {{True, True}, {True, True}}, FontSize -> 20]}, 
  Dimensions -> {1, 2}, XPanelSizes -> {1, 0.05}, 
  ShowTickLabels -> True, XPanelGaps -> 0.05, PanelLetter -> None], 
 CanvasSize -> {3.4, 3.4}]

enter image description here

It is very obvious.

But if I only plot one panel, without the colorbar. Everything is normal again.

Figure[FigurePanel[{FigGraphics[testfig]}, XPlotRange -> {0, 1}, 
  YPlotRange -> {0, 1}, 
  XFrameLabel -> Subscript[textit["\[Alpha]"], 1], 
  XTicks -> LinTicks[-1, 1, 0.5, 1], YTicks -> LinTicks[0, 2, 0.5, 1],
   YFrameLabel -> Subscript[textit["\[Alpha]"], 2], FontSize -> 20], 
 CanvasSize -> {3.4, 3.4}]

enter image description here

So what happened when I use multipanel to combine a density plot and a bar legend? Why is the data region shifted? I am using SciDraw 0.07 and Mathematica 12.0. Thanks!

$\endgroup$

1 Answer 1

1
$\begingroup$

I used the code that you mentioned, but I can't reproduce the problem you mentioned. I am using Mathematica 12.1 and the latest version of SciDraw. The output of your code in my case looks as follows:enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks! I was using 12.0 at the time when I asked this question. $\endgroup$
    – Jake Pan
    Commented Dec 20, 2020 at 16:15

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.