5
$\begingroup$

I am trying to write a report and need to create some plots of my data. One of the plots is made from 3 individual plots on the same line with no gap between them. The leftmost plot y axis has tics with label, while the rest have only tics but no labels. There is a label on the left side of this multi plot and at the bottom. I can do all this in gnuplot but it is cumbersome and I need to do a few of these things. Is there a simple way to do this?

I will attempt a simple working example below.

There are several problems with what I have so far:

  1. the object that results from using Labeled is not selectable together with the labels. I can select and copy all the plots but not the labels. So I cannot copy and paste the plot into my report document. I could do a printscreen of the plot but I would like to avoid this.
  2. I cannot get rid of the tic labels and maintain only the tics for the plot in the middle and right.
  3. I cannot figure out how to have all the plots drawn with the same axis limits.
  4. Although I set the Spacigs to 0 there is still a gap between plots.
test1 = ListPlot[RandomReal[0.5, 3.], PlotTheme -> "FrameGrid", 
   PlotRange -> All, Joined -> True, PlotStyle -> {Red, Blue, Green}, 
   Mesh -> All, ImageSize -> 600, 
   PlotLegends -> Placed[{"test1"}, {0.5, 0.2}],
   BaseStyle -> {FontFamily -> "Times New Roman", FontSize -> 12}, 
   Frame -> True, FrameStyle -> Directive[Thick, Large, Black]];
test2 = ListPlot[RandomReal[-1., 1.], PlotTheme -> "FrameGrid", 
   PlotRange -> All, Joined -> True, PlotStyle -> {Red, Blue, Green}, 
   Mesh -> All, ImageSize -> 600, 
   PlotLegends -> Placed[{"test2"}, {0.5, 0.2}],
   BaseStyle -> {FontFamily -> "Times New Roman", FontSize -> 12}, 
   Frame -> True, FrameStyle -> Directive[Thick, Large, Black]];
test3 = ListPlot[RandomReal[3., 6.], PlotTheme -> "FrameGrid", 
   PlotRange -> All, Joined -> True, PlotStyle -> {Red, Blue, Green}, 
   Mesh -> All, ImageSize -> 600, 
   PlotLegends -> Placed[{"test3"}, {0.5, 0.2}],
   BaseStyle -> {FontFamily -> "Times New Roman", FontSize -> 12}, 
   Frame -> True, FrameStyle -> Directive[Thick, Large, Black]];

Labeled[
 GraphicsGrid[
  {{test1, test2, test3}}, Frame -> None, ImageSize -> 1200, 
  Spacings -> {0, 0}
  ],
 {Pane["Left side label"], "Bottom label"}, {Left, Bottom}, 
 RotateLabel -> True, 
 LabelStyle -> 
  Directive[Bold, FontFamily -> "Times New Roman", FontSize -> 24]
 ]
```
$\endgroup$
3
  • $\begingroup$ Take a look at resource function called PlotGrid. $\endgroup$
    – Syed
    Nov 29, 2022 at 15:21
  • $\begingroup$ oh that's nice! I'll check it out! Thanks! $\endgroup$
    – lucian
    Nov 29, 2022 at 15:27
  • $\begingroup$ That resource is really cool! The only problem I have with it is that it ignores Epilog. I am adding some text to the individual plots with Epilog and when it combines them, there is no text present. Maybe there is something that I haven't discovered yet! $\endgroup$
    – lucian
    Nov 29, 2022 at 16:38

2 Answers 2

4
$\begingroup$

Using ResourceFunction["PlotGrid"]:

ResourceFunction["PlotGrid"][
 {{test1, test2, Show[test3, Epilog -> {Text["Some epilog", Scaled@{0.5, 0.5}]}]}},
 PlotRange -> Max,
 ImageSize -> 1200,
 FrameLabel -> {"Bottom label", "Left side label"},
 FrameStyle -> Directive[Black, Bold, FontFamily -> "Times New Roman", FontSize -> 24]
 ]

enter image description here

$\endgroup$
1
  • $\begingroup$ thank you! this is it! $\endgroup$
    – lucian
    Nov 30, 2022 at 0:24
3
$\begingroup$

Try the following:

test1 = ListPlot[RandomReal[0.5, 3.], PlotTheme -> "FrameGrid", 
   PlotRange -> All, Joined -> True, PlotStyle -> {Red, Blue, Green}, 
   Mesh -> All, ImageSize -> 320, 
   PlotLegends -> Placed[{"test1"}, {0.5, 0.2}], Frame -> True, 
   FrameStyle -> Directive[Thick, Large, Black], 
   FrameLabel -> {None, Style["Label1", 16, Black, Bold]}, 
   FrameTicksStyle -> Directive[{Black, 12}]];
test2 = ListPlot[RandomReal[-1., 1.], PlotTheme -> "FrameGrid", 
   PlotRange -> All, Joined -> True, PlotStyle -> {Red, Blue, Green}, 
   Mesh -> All, ImageSize -> 300, Frame -> True, 
   FrameStyle -> Directive[{Thick, Large, Black}], 
   FrameLabel -> {None, None}, 
   FrameTicksStyle -> Directive[{Black, 12}]];
test3 = ListPlot[RandomReal[3., 6.], PlotTheme -> "FrameGrid", 
   PlotRange -> All, Joined -> True, PlotStyle -> {Red, Blue, Green}, 
   Mesh -> All, ImageSize -> 290, 
   PlotLegends -> Placed[{"test3"}, {0.5, 0.2}], Frame -> True, 
   FrameStyle -> Directive[{Thick, Large, Black}], 
   FrameLabel -> {None, None}, 
   FrameTicksStyle -> Directive[{Black, 12}]];


Rasterize[Column[{
   Grid[{{test1, test2, test3}}],
   Row[{Spacer[430], Style["Label2", 16, Black, Bold]}]
   }], RasterSize -> 1200, ImageSize -> {900, Automatic}]

yielding the following:

enter image description here

Now you may play a bit with the arguments of the three ImageSize options of each test to adjust their relative sizes, as well as with the argument of the Spacer to adjust the position of the bottom label and the RasterSize to play with the image quality.

Have fun!

$\endgroup$
3
  • $\begingroup$ but what about setting the same y axis range for all three plots and getting rid of the tic labels for the middle and rightmost plot? $\endgroup$
    – lucian
    Nov 29, 2022 at 15:29
  • $\begingroup$ The same range you can fix by the PlotRange option and get rid of ticks by the proper choice of the Ticks option. Please have a look at the documentation. $\endgroup$ Nov 29, 2022 at 15:38
  • $\begingroup$ thanks man! yep the documentation! i have not seen that at all. I just jumped here and started asking questions. $\endgroup$
    – lucian
    Nov 29, 2022 at 15:46

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.