4
$\begingroup$

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?

$\endgroup$
2
  • 1
    $\begingroup$ 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. $\endgroup$
    – Jason B.
    Oct 3, 2017 at 14:10
  • $\begingroup$ @JasonB. Works well... Thanks. $\endgroup$
    – ercegovac
    Oct 3, 2017 at 14:13

1 Answer 1

9
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – ercegovac
    Oct 3, 2017 at 14:30

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.