4
$\begingroup$

I think I started to notice this issue with plots when I updated to version 12.3 a couple weeks ago but didn't pay too much attention. Now it's really bugging me because I have a presentation of this data coming up. (Please note I changed the code a bit for privacy but it still shows the behaviour.)

Looking at other PlotLabel posts on SE and the docs, I'm a bit confused as to why the plot label isn't sitting neatly above the plot as expected. I tried a couple of tweaks with ImagePadding etc. and tried removing all the graphics options except PlotLabel to no avail. I don't really want to use Labelled either since it should be working more predictably in my opinion.

Any ideas? Is there an explanation for this? Is anyone else seeing this behaviour in 12.3 with PlotLabel?

MakeTimeSeriesGraphic[ds_] := 
 Module[{tally, g, prod, dates},
  prod = ds[1] // Values // First;
  dates = FromDateString[#, DateFormat -> "ISODate"] & /@ (ds[All, "date"] // Normal);
  tally =  Tally[dates];
  g = TimeSeries[tally, {dateStart, dateEnd}, MissingDataMethod -> {"Constant", 0 }];
  DateListPlot[
   g,
   PlotTheme -> "Scientific",
   GridLines -> Automatic,
   PlotLabel -> Style[prod, "Subitem"],
   PlotStyle -> SelectColor,
   PlotRange -> All,
   ImagePadding -> {{Automatic, Automatic}, {Automatic, 1}}
   ]
  ]

Block[{var},
 var = Table[MakeTimeSeriesGraphic[data[i]], {i, Length@data}];
 GraphicsGrid[
  Partition[var, 4],
  ImageSize -> 960,
  Spacings -> Scaled[0.01],
  Frame -> All
  ]
 ]
$\endgroup$
6
  • $\begingroup$ I get an error GraphicsGrid::list: {} is not a list of lists. when running your code on 12.3 $\endgroup$
    – Nasser
    Jun 24, 2021 at 2:31
  • $\begingroup$ dates code was missing. Should work now with some synthetic data in into Tally. $\endgroup$
    – BBirdsell
    Jun 24, 2021 at 3:42
  • 1
    $\begingroup$ still does not work. same error. What happens if open a new notebook, with clean kernel, and paste the same code you posted there into a cell, and run your code copied from the above? There is no data. MWE should be self contained to be to run it. $\endgroup$
    – Nasser
    Jun 24, 2021 at 4:23
  • 1
    $\begingroup$ I've seen this type of issue before when working on my version of GraphicsGrid. Essentially, the issue is that PlotLabel is placed outside of the ImagePadding, but is included in ImagePadding when measuring it. This means that GraphicsGrid leaves enough space for PlotLabel with the ImagePadding setting, but it then gets placed outside anyway. Until they fix it, I you can use either the top FrameLabel instead of PlotLabel, or you can try ResourceFunction["PlotGrid"] (which can add the grid however) $\endgroup$
    – Lukas Lang
    Jun 24, 2021 at 7:52
  • $\begingroup$ (there's a typo in the last part of the above comment: PlotGrid cannot add the gridlines) $\endgroup$
    – Lukas Lang
    Jun 24, 2021 at 7:58

1 Answer 1

3
$\begingroup$

Thanks to user Lukas Lang's helpful comment, FrameLabel does appear to be a predictable workaround for this issue. Using the below code returns the correct placement.

FrameLabel -> {{None, None}, {None, Style[prod, "Subitem"]}}
$\endgroup$

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.