0
$\begingroup$

I would like to remove y-axes with keeping plot's consistency and then save it as pdf without cell number (I used save selection as), it is Ok if saved as an image but not working with pdf?! Here the used code:

t1=DensityPlot[Sin[y]^2 Cos[6 x], {x, -2, 2}, {y, 0, 5},ImageSize -> 240, Frame -> True, ImagePadding -> {{40, 0}, {50, 5}},FrameLabel -> {"x", "y"}, ColorFunction -> "Rainbow",PlotPoints -> 50]  

t2=DensityPlot[Sin[y]^2 Cos[3 x], {x, -2, 2}, {y, 0, 5},ImageSize -> 240, Frame -> True, ImagePadding -> {{40, 0}, {50, 5}},FrameLabel -> {"x", "y"}, ColorFunction -> "Rainbow",PlotPoints -> 50]

t3=DensityPlot[Sin[y]^2 Cos[4 x], {x, -2, 2}, {y, 0, 5},ImageSize -> 240, Frame -> True, ImagePadding -> {{40, 0}, {50, 5}},FrameLabel -> {"x", "y"}, ColorFunction -> "Rainbow",PlotPoints -> 50]

t4=DensityPlot[Sin[y]^2 Cos[2 x], {x, -2, 2}, {y, 0, 5},ImageSize -> 240, Frame -> True, ImagePadding -> {{40, 0}, {50, 5}},FrameLabel -> {"x", "y"}, ColorFunction -> "Rainbow",PlotPoints -> 50]  

Legended[GraphicsGrid[Partition[{t1, t2, t3, t4}, 2],Spacings -> {-70,-70}],Placed[BarLegend[{"Rainbow", {-1, 1}},LabelStyle -> {FontSize -> 12,Red, Bold},LegendMarkerSize -> 200], {{1.52, .59}}]]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ like this: mathematica.stackexchange.com/q/6877/5478? $\endgroup$ – Kuba Mar 14 '17 at 11:28
  • $\begingroup$ But this is not working for Density plot? $\endgroup$ – HD2006 Mar 14 '17 at 11:44
  • $\begingroup$ Have you tried? $\endgroup$ – Kuba Mar 14 '17 at 11:48
  • $\begingroup$ Yes, I found the post earlier and tried to implement it to density plot but could not $\endgroup$ – HD2006 Mar 14 '17 at 11:51
  • 1
    $\begingroup$ Jens' answer work out of hand for me, could you elaborate? $\endgroup$ – Kuba Mar 14 '17 at 11:52
1
$\begingroup$

I would use LevelScheme for this. Clearly, it's more involved than GraphicsGrid[]. However, the control is unbeatable.

Load package & set defaults

Needs["LevelScheme`LevelScheme`"]
A4LEN = (11 3)/4;
SetOptions[DensityPlot, 
  ColorFunction -> "Rainbow", 
  PlotPoints -> 50];

define a color bar

cbar = ContourPlot[y, {x, 0, 1}, {y, -1, 1},
  ColorFunction -> ColorData["Rainbow"],
  ColorFunctionScaling -> True,
  Contours -> 50,
  PlotRange -> {{0, 1}, {-1, 1}}
  ];

then construct the figure using

ofig = Figure[{
   SetOptions[SchemeObject, FontFamily -> "Helvetica", FontSize -> 10],
   ScaledLabel[{.5, .97}, "Title", FontSize -> 12, 
    FontWeight -> Bold, Offset -> {0, 0}],
   ScaledLabel[{.5, .94}, "Subtitle", FontSize -> 10, 
    FontSlant -> Italic, Offset -> {0, 0}],
   Multipanel[{{0, 1}, {0, 1}}, {2, 3},
    Margin -> 50,
    XPlotRanges -> {{-2, 2}, {-2, 2}, {0, 1}},
    YPlotRanges -> {{0, 5}, {0, 5}},
    XFrameLabels -> {"X", "X", ""}, BufferB -> 5,
    YFrameLabels -> {"Y", "Y"}, BufferL -> 7,
    XFrameTicks -> {LinTicks[-2, 2, 1, 1], LinTicks[-2, 2, 1, 1],
      LinTicks[0, 1, 1, 1]},
    YFrameTicks -> {
      {LinTicks[0, 5, 1, 1], LinTicks[0, 5, 1, 1], 
       LinTicks[-1, 1, .5, 1]},
      {LinTicks[0, 5, 1, 1], LinTicks[0, 5, 1, 1], 
       LinTicks[-1, 1, 1, 1]}},
    YGapSizes -> .1, XGapSizes -> {.1, .2},
    YPanelSizes -> {1, 1},
    XPanelSizes -> {1, 1, .1},
    Order -> Vertical, ShowPanelLetter -> False
    ],
   FigurePanel[{1, 1}],
   RawGraphics@DensityPlot[Sin[y]^2 Cos[6 x], {x, -2, 2}, {y, 0, 5}],
   FigurePanel[{2, 1}],
   RawGraphics@DensityPlot[Sin[y]^2 Cos[4 x], {x, -2, 2}, {y, 0, 5}],
   FigurePanel[{1, 2}],
   RawGraphics@DensityPlot[Sin[y]^2 Cos[3 x], {x, -2, 2}, {y, 0, 5}],
   FigurePanel[{2, 2}], 
   RawGraphics@DensityPlot[Sin[y]^2 Cos[2 x], {x, -2, 2}, {y, 0, 5}],
   FigurePanel[{1, 3}, ShowPanelLetter -> False, 
    ShowTickLabels -> {False, True, False, False},
    XPlotRange -> {0, 1}, YPlotRange -> {-1, 1}, 
    PanelAdjustments -> {{0, 0}, {.75, -.35}}],
   ScaledLabel[{1, .5}, "Lable", Offset -> {0, -2}, 
    Orientation -> -90 \[Degree]],
   RawGraphics@cbar
   },
  ImageSize -> (1*72) *  {A4LEN, A4LEN} (* adjust for page size *)
  ]

image ...

Save as PDF using

Export["test.pdf", ofig];
$\endgroup$
  • $\begingroup$ Thanx a lot! @dwa $\endgroup$ – HD2006 Mar 15 '17 at 0:57

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.