0
$\begingroup$

I would like to plot a row of three (maybe 4 or 5) ListDensityPlot and the export it as .eps (to use in a paper written in Latex). I want the same bar legend for all plots. Something like what is described here:

Fixed color scale in multiple density plots

but with the bar legend included. And also with each picture having its own axis labels.

Here is a sample:

data1 = Table[{ll, kk, RandomReal[{ll, kk}]}, {kk, 1, 100}, {ll, 1, 
100}];

data2 = Table[{ll, kk, 0.95*RandomReal[{ll, kk}]}, {kk, 1, 100}, {ll, 
1, 100}];

data3 = Table[{ll, kk, 0.80*RandomReal[{ll, kk}]}, {kk, 1, 100}, {ll, 
1, 100}];

g1 = data1 // Flatten[#, 1] & // 
ListDensityPlot[#, FrameLabel -> {Style["x1", 20], Style["y1", 20]},
 FrameTicksStyle -> Directive[20], AspectRatio -> 1, 
PlotRange -> All, InterpolationOrder -> 0] &

g2 = data2 // Flatten[#, 1] & // 
ListDensityPlot[#, FrameLabel -> {Style["x2", 20], Style["y2", 20]},
 FrameTicksStyle -> Directive[20], AspectRatio -> 1, 
PlotRange -> All, InterpolationOrder -> 0] &

g3 = data3 // Flatten[#, 1] & // 
ListDensityPlot[#, FrameLabel -> {Style["x3", 20], Style["y3", 20]},
FrameTicksStyle -> Directive[20], AspectRatio -> 1, 
PlotRange -> All, InterpolationOrder -> 0, 
PlotLegends -> 
 Placed[BarLegend[Automatic, 8, LegendLabel -> Style["z", 20], 
   LegendMarkerSize -> 300], Right]] &

I tried to glue them using:

GraphicsRow[{g1, g2, g3}, Spacings -> {0, 0}, Frame -> None, AspectRatio -> 1, ImageSize -> 1000]

but there is an issue with the size of the last Plot.

What could I do? Any help much appreciated!

$\endgroup$

1 Answer 1

2
$\begingroup$
data1 = Table[{ll, kk, RandomReal[{ll, kk}]}, {kk, 1, 100}, {ll, 1, 
    100}];
data2 = Table[{ll, kk, 0.95*RandomReal[{ll, kk}]}, {kk, 1, 100}, {ll, 
    1, 100}];
data3 = Table[{ll, kk, 0.80*RandomReal[{ll, kk}]}, {kk, 1, 100}, {ll, 
    1, 100}];

g1 = data1 // Flatten[#, 1] & // 
   ListDensityPlot[#, 
     FrameLabel -> {Style["x1", 20], Style["y1", 20]}, 
     FrameTicksStyle -> Directive[20], AspectRatio -> 1, 
     PlotRange -> {{0, 100}, {0, 100}}, InterpolationOrder -> 0, 
     ImageSize -> 300] &;

g2 = data2 // Flatten[#, 1] & // 
   ListDensityPlot[#, 
     FrameLabel -> {Style["x2", 20], Style["y2", 20]}, 
     FrameTicksStyle -> Directive[20], AspectRatio -> 1, 
     PlotRange -> {{0, 100}, {0, 100}}, InterpolationOrder -> 0, 
     ImageSize -> 300] &;

g3 = data3 // Flatten[#, 1] & // 
   ListDensityPlot[#, 
     FrameLabel -> {Style["x3", 20], Style["y3", 20]}, 
     FrameTicksStyle -> Directive[20], AspectRatio -> 1, 
     PlotRange -> {{0, 100}, {0, 100}}, InterpolationOrder -> 0, 
     ImageSize -> 300
     ] &;
g4 = data3 // Flatten[#, 1] & // 
  ListDensityPlot[#, Frame -> None, PlotStyle -> None, 
    AspectRatio -> 4, PlotRange -> {{0, 20}, {0, 100}}, 
    InterpolationOrder -> 0, ImageSize -> {100, 300}
    , PlotLegends -> 
     Placed[BarLegend[Automatic, 8, LegendLabel -> Style["z", 20], 
       LegendMarkerSize -> 250], {0.55, 0.55}]
    ] &

Using GraphicsRow:

GraphicsRow[{g1, g2, g3, g4}, Spacings -> {{0, 0, 0, 0}, 0}, 
 Frame -> None, AspectRatio -> Automatic, ImageSize -> 1150]

enter image description here

Using Frame:

Framed[Grid[{{g1, g2, g3, g4}}, Frame -> None], 
 Background -> Lighter@Yellow, FrameStyle -> {Dashed, Red}]
$\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.