Message Boards Message Boards

2 Replies
2 Total Likes
View groups...
Share this post:

drawing only part of the axes

I have a figure which spans, say [-1,1] x [-1,1].
I would like to draw only part of the axes, say [0,1] x {0} union with {0} x [0,1], instead of the normal [-1,1] x {0} union with {0} x [-1,1].
Of course, one possibility would be to draw no axes and construct some myself, with ticks, labels, etc.
But this is not an efficient solution given that I have several complex figures.
I also tried drawing a thick white line over the part of the axes that I don't want to see but this does not work because it seems the axes are drawn last.
I would very much appreciate it if someone would help me out.
POSTED BY: Pedro Girão
2 Replies
You can control whether added graphic element to a plot are drawn before or after the plot is generated by choosing between Prolog and Epilog options.

Graphics[{Red, Disk[]}, Prolog -> {Green, Rectangle[]}]


Graphics[{Red, Disk[]}, Epilog -> {Green, Rectangle[]}]

However, drawing white lines over parts of the axes to cover portions of the underlying aready-rendered axes may have unintended consequences (AKA, it's a hack).  A better way for you to do this is to set the option AxesStyle -> Directive[Opacity[0]] and then add the portions of the axes perhaps along this approach:
Plot[x, {x, 0, 3}, TicksStyle -> Directive[Opacity[1]],
AxesStyle -> Directive[Opacity[0]],
Epilog -> {Line[{{{0, 0}, {1, 0}}, {{2, 0}, {3, 0}}}],
   Line[{{{0, 1}, {0, 2}}}]}]
POSTED BY: David Reiss
Thank you very much, David Reiss.
You solved my problem!

Best regards,
Pedro Girão
POSTED BY: Pedro Girão
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract