4

I was trying to draw some plots where I wanted to add Arrowheads to axes. However, these would completely wreck the plot, putting it completely off the scale. This issue was already discussed in this question, and @Dr. belisarius offered a solution.

Now I'm facing another problem. If I want to set AxesLabel property along with AxesStyle->Arrowheads[{0,0.05}], the axes labels are not shown when ImagePadding->None. (I'll use examples from the aforementioned question to illustrate)

Plot[1/x^5, {x, -20, 20}, AxesStyle -> Arrowheads[{0.0, 0.05}], 
    ImagePadding -> #, AxesLabel -> {"lbl", None}, 
    ImageSize -> Medium] & /@ {None, All} // 
 GraphicsRow[#, Frame -> All] &

enter image description here

Am I mistaken or this seams as a bug related to the question before? Does anybody has some solution/workaround?

ercegovac
  • 1,017
  • 8
  • 17
  • 1
    This is an annoying bug, but the workaround isn't to set the ImagePadding to None, but to set it the actual value you want. Try ImagePadding -> {{0, 30}, {0, 0}}, and then adjust the ${{left, right}, {top, bottom}}$ values to your needs. – Jason B. Oct 03 '17 at 14:10
  • @JasonB. Works well... Thanks. – ercegovac Oct 03 '17 at 14:13

1 Answers1

9

You can use my graphicsInformation function to determine the required explicit ImagePadding. Apply the function to the plot with default ImagePadding:

plot = Plot[1/x^5, {x,-20,20}, AxesLabel->{"lbl",None}];
padding = "ImagePadding" /. graphicsInformation[plot]

{{1.71429, 19.}, {1.5, 0.5}}

Then, use this ImagePadding in your plot:

Show[plot, AxesStyle->Arrowheads[{0.0, 0.05}], ImagePadding -> padding]

enter image description here

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
  • The question to which you posted the original answer incidentally is another issue with which I'm currently struggling (aligning images). Thanks, you saved me a lot of time. – ercegovac Oct 03 '17 at 14:30