1
$\begingroup$

I have constructed this contour plots for a project

ContourPlot[
  (2.1 - a^2 + 2.1 b) (-2 + (2.1 (1 + b))/a^2),
  {a, -1.5, -0.5}, {b, -1, 1},
  PlotRange -> All,
  ContourShading -> {RGBColor[0.16, 0.5, 0.5], RGBColor[0.51, 0.35, 0.25]},
  Contours -> {Automatic, 1},
  PlotLegends ->
   {BarLegend[Automatic, LegendMarkerSize -> 180, 
     LegendFunction -> "Frame", LegendMargins -> 5]},
  PlotLabel -> "Contour Plot", LabelStyle -> {Thick, Black},
  Mesh -> 1, MeshStyle -> Red, MeshFunctions -> {#1 &}
]

I have also the following contours

g2=(2.1 + (-1. - 6.6 a) a^2 + 2.1 (1 - 0.6 a^3) b) (-2. + (2.1 (1 + b))/   a^2 - 0.2 a (33 + 6.3 b))
g3=(2.1 + a^2 (-1. + 6.6 a) + 2.1 (1 + 0.6 a^3) b) (-2. + (2.1 (1 + b))/   a^2 + 0.2 a (33 + 6.3 b))
g4=(2.1 + a^2 (-1. + 14. a^2) + 2.1 (1 + 2. a^4) b) (-2. -    2. a^2 (-7 - 2.1 b) + (2.1 (1 + b))/a^2)

and I want to combine the four contours with GraphicsGrid and have a common BarLegend in the bottom of the figure (similar to the bar legend of the first contour plot). However I was unable to do that. Any suggestions?

$\endgroup$

1 Answer 1

1
$\begingroup$

This is kinda intro. You can improve this. You should define different range for each plot.

g = {(2.1 - a^2 + 
      2.1 b) (-2 + (2.1 (1 + b))/a^2), (2.1 + (-1. - 6.6 a) a^2 + 
      2.1 (1 - 0.6 a^3) b) (-2. + (2.1 (1 + b))/a^2 - 
      0.2 a (33 + 6.3 b)), (2.1 + a^2 (-1. + 6.6 a) + 
      2.1 (1 + 0.6 a^3) b) (-2. + (2.1 (1 + b))/a^2 + 
      0.2 a (33 + 6.3 b)), (2.1 + a^2 (-1. + 14. a^2) + 
      2.1 (1 + 2. a^4) b) (-2. - 
      2. a^2 (-7 - 2.1 b) + (2.1 (1 + b))/a^2)};

Legended[Multicolumn[
  Table[ContourPlot[g[[i]], {a, -1.5, -0.5}, {b, -1, 1}, 
    PlotRange -> All, 
    ContourShading -> {RGBColor[0.16, 0.5, 0.5], 
      RGBColor[0.51, 0.35, 0.25]}, Contours -> {Automatic, 1}, 
    PlotLabel -> "Contour Plot", LabelStyle -> {Thick, Black}, 
    Mesh -> 1, MeshStyle -> Red], {i, 4}], 2], 
 Placed[BarLegend[{{RGBColor[0.16, 0.5, 0.5], 
     RGBColor[0.51, 0.35, 0.25]}, {-1, 1}}, {-1, 0, 1}, 
   LegendLayout -> "Row", LegendMarkerSize -> 300, 
   LegendFunction -> "Frame", LegendMargins -> 5], Bottom]]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks a lot! It is perfect! $\endgroup$
    – Smaug
    May 7, 2018 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.