2
$\begingroup$

I'm trying to insert a ragged line on a plot axis by using an inset. However, I always get white space around the inset such that my axis is broken at some point. What can I do to remove the white space?

Plot[x, {x, 0, 1}, ImageSize -> 300, 
Epilog -> {{Inset[
 Style[
  Graphics[
   {Thickness[0.02],
    Line[{{-0.1,0},{0,0},{0.2,0.2},{0.6,-0.2},{1,0.2},{1.2,0},{1.3,0}}]}, 
  ImageSize -> 15], 
  Background -> White],
  {0.5, 0}]}},
  ImagePadding -> 15,PlotRangeClipping -> False]

enter image description here

$\endgroup$
  • $\begingroup$ Is there a specific reason why you use this whole Inset[Style[Graphics[Line[...] ...]]] and not just give the graphics directive directly in Epilog, like Epilog -> {White, Rectangle[{0.475, -.1}, {.525, .1}], Black, Thickness[0.002], Line[...]}? $\endgroup$ – Theo Tiger Apr 5 '18 at 13:04
  • $\begingroup$ There is no specific reason other than my limited knowledge about alternatives. $\endgroup$ – Fabian Apr 5 '18 at 16:26
1
$\begingroup$

Just add PlotRangePadding -> 0, ImagePadding -> 0 to the inner Graphics object.

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