2
$\begingroup$

I am running into an issue whereby my Y frame label (I want to use this rather than an axis label to make the label vertical), is being cutoff when I view the graph.

See below for an indicative example. I would like the y axis label to be "Probability of extinction", but for some reason, the displayed graph has the 'n' of extinction cutoff.

ListPlot[Thread[{Range[4], Table[RandomReal[], {4}]}], 
 Axes -> {True, True}, FrameLabel -> {"Probability of extinction"}, 
Frame -> {True, True, False, False}, BaseStyle -> {FontSize -> 16}]

enter image description here

Can anyone advise on how to prevent this from happening? I have tried ImagePadding and ImageMargins, but neither seem to help.

Best,

Ben

$\endgroup$
  • $\begingroup$ Can you give a minimal example that illustrates the problem, mention your Mathematica version and your operating system? I have never seen this problem, so I assume that it only happens under special conditions. Let's find out what those conditions are. Also, since you signed the question, could you set an easier to remember name in your profile than "user2003951"? $\endgroup$ – Szabolcs Dec 9 '14 at 16:58
  • $\begingroup$ @Szabolcs - sorry about that; I meant to include my code. Please see the amendments above. Best, Ben $\endgroup$ – ben18785 Dec 9 '14 at 17:05
  • $\begingroup$ On my system, your code doesn't give your figure. Nevertheless, try simply typing a space after the n, as in "Probability of extinction ". $\endgroup$ – David G. Stork Dec 9 '14 at 17:08
  • $\begingroup$ @DavidG.Stork - Yes, that is a simple workaround! Thanks, Ben $\endgroup$ – ben18785 Dec 9 '14 at 17:09
  • $\begingroup$ Could you mention the version of your Mathematica and your operating system, so we can properly tag the question? I am unable to reproduce the problem on OS X, either in M9 or M10. Based on your and kguler's screenshots, is it M9 on Windows? $\endgroup$ – Szabolcs Dec 9 '14 at 17:17
4
$\begingroup$
dt = RandomInteger[10, 10]; 

The following reproduces the issue (Version 9.0.1.0 Windows 8 64bit) with large enough font size for the frame labels:

lp1 = ListPlot[dt, ImageSize -> 400, Frame -> {True, True, False, False}, 
  FrameLabel -> {None, Style["Probability of extinction", 16], None,  None}]

enter image description here

You can wrap the labels with Framed or Pane with appropriate setting for the ImageMargins to prevent the cropping:

lp2 = ListPlot[dt, ImageSize -> 400, Frame -> {True, True, False, False}, 
   FrameLabel -> {None, 
    Framed[Style["Probability of extinction", 16], FrameStyle -> None], None, None}]

enter image description here

lp3 = ListPlot[dt, ImageSize -> 400, Frame -> {True, True, False, False}, 
   FrameLabel -> {None, 
     Pane[Style["Probability of extinction", 16], ImageMargins -> {{0, 1}, {0, 0}}], None, None}]

enter image description here

Update: You can use the FontTracking option of Style to deal with the issue mentioned by @funnypony in the comments:

still another problem appears if you type "!" in the end

ListPlot[dt, ImageSize -> 500, Frame -> {True, True, False, False}, 
 FrameLabel -> {None, Framed[Style["Probability of extinction!", 16], FrameStyle -> None], 
                None, None}]

enter image description here

ListPlot[dt, ImageSize -> 500, Frame -> {True, True, False, False}, 
  FrameLabel -> {None, Framed[Style["Probability of extinction!", 16, FontTracking -> "Extended"],
         FrameStyle -> None], None, None}]

enter image description here

$\endgroup$
  • $\begingroup$ still another problem appears if you type "!" in the end: i.imgur.com/BRtrWaO.png $\endgroup$ – funnyp0ny Dec 9 '14 at 17:46
  • $\begingroup$ @funnypony, updated with a way to deal with the "!" issue. $\endgroup$ – kglr Dec 9 '14 at 17:59
3
$\begingroup$

It seems there's a problem when mathematica renders the output image in some cases:

enter image description here

Thats label for 18-22 font sizes, evidently it doesn't smoothly work for 19, 20, 21. But since you increase the quality - everthing becomes perfect:

Rasterize[ListPlot[{{1, 2}}, FrameLabel -> {"", "Probability of extinction!"}, 
   Frame -> True, FrameStyle -> 20], ImageResolution -> 500]

enter image description here

The simplest solution though is just to use occasionally spaces at the end, as mentioned in comments, or different font sizes.

$\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.