2
$\begingroup$

I'm having some trouble with PlotLabel overlapping with AxesLabel, when the values of the points being plotted are large in absolute size. The following example shows my issue:

e = 10^17;
GraphicsRow[{ListLinePlot[{{-1 e, -4 e}, {2 e, -8 e}, {3 e, 3 e}, {-2 e, 1 e}}, 
   AxesLabel -> {"xxxx", "yyyy"}, PlotLabel -> "Label that should not overlap"]}]

plot with labels superimposed

Without the GraphicsRow, the labels don't overlap until I resize the image, at which point the label jumps down to overlap the axis label. For smaller values of e, I have no issues.

Is this a bug? Is there a workaround to fix this automatically? My actual use-case includes the showing of two plots in a GraphicsRow.

$\endgroup$
6
$\begingroup$

Update: Adding the option ImagePadding -> Scaled[.1] prevents the issue:

llp2 = ListLinePlot[{{-1 e, -4 e}, {2 e, -8 e}, {3 e, 3 e}, {-2 e, 1 e}}, 
 AxesLabel -> {"xxxx", "yyyy"}, 
 PlotLabel -> "Label that should not overlap", 
 ImagePadding -> Scaled[.1]];
GraphicsRow[{llp2, llp2}]

enter image description here

Original answer:

You can add the plot labels using Labeled:

ListLinePlot[{{-1 e, -4 e}, {2 e, -8 e}, {3 e, 3 e}, {-2 e, 1 e}}, 
  AxesLabel -> {"xxxx", "yyyy"}, 
  PlotLabel -> "Label that should not overlap"] 

enter image description here

llp = Labeled[ListLinePlot[{{-1 e, -4 e}, {2 e, -8 e}, {3 e, 3 e}, {-2 e, 1 e}}, 
   AxesLabel -> {"xxxx", "yyyy"}], "Label that should not overlap",  Top]

enter image description here

GraphicsRow[{llp, llp}]

enter image description here

$\endgroup$
  • $\begingroup$ The scaled ImagePadding solution looks awful if you take it out of the GraphicsRow. I think the Labelled option is better for my need. $\endgroup$ – KraZug Jul 20 '18 at 8:16
2
$\begingroup$

Or a simple hack:

PlotLabel -> "Label that should not overlap\n"]}

or if you want to adjust the separation:

e = 10^17;
ListLinePlot[{{-1 e, -4 e}, {2 e, -8 e}, {3 e, 3 e}, {-2 e, 1 e}}, 
 AxesLabel -> {"xxxx", "yyyy"},
 PlotLabel -> 
  Text[Style["Label that should not overlap", 
    LineSpacing -> {-1, 0}]]]
$\endgroup$
  • 1
    $\begingroup$ And why the down-vote for a technique that is extremely simple and always works? $\endgroup$ – David G. Stork Jul 19 '18 at 17:37
  • $\begingroup$ While this answer creates excessive space between the two labels, it certainly does not merit a down-vote. $\endgroup$ – bbgodfrey Jul 19 '18 at 18:59
  • 2
    $\begingroup$ If you do that and then adjust the size of the plot manually, the plot label still jumps on top of the axis label. $\endgroup$ – KraZug Jul 20 '18 at 8:14

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.