Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to remove the numbering on the axes of the following RegionPlot. I would like to keep the tick marks but drop the numbering, I haven't figured out how to do this from the documentation.

The inverse image of the interval (a,b) under the metric function d

share|improve this question
3  
Can you give a code sample that generates that plot? –  Eli Lansey Feb 21 '12 at 2:37

4 Answers 4

up vote 14 down vote accepted

An even simpler way that does not require you to figure out the tick positions, is to set the tick font opacity to 0 and the tick font size to 0 to avoid the excess margin where the ticks would have been. Here's an example:

RegionPlot[Sin[x y] > 0, {x, -1, 1}, {y, -1, 1}, 
    FrameTicksStyle -> Directive[FontOpacity -> 0, FontSize -> 0]]

enter image description here

Alternately, you could also use FontColor -> White, but note that it won't work with all backgrounds.

share|improve this answer
    
+1 Nice and simple. –  David Carraher Feb 21 '12 at 3:23
    
I just posted the same thing with FontOpacity, then deleted it when I saw that you had already mentioned it. I would just add FontSize->0 to reduce the blank space in the image margins. –  Jens Feb 21 '12 at 3:38
    
Thanks, I had FontSize -> 0 in my test code, but threw it out in the end. I've included it now and made FontOpacity the primary suggestion (it certainly is superior to FontColor) –  rm -rf Feb 21 '12 at 4:45
    
I like this solution the best, as I am using a Show to layer multiple graphics –  Tobi Lehman Feb 21 '12 at 18:14

My preferred solution is playing with FontColor or FontOpacity as in R.M.`s answer, or define your own ticks as in David's answer.

Another alternative is to change the labels to blank in FrameTicks. Since FrameTicks->Automatic saves a lot manual effort (and it uses the built-in FindDivisions for selecting ticks), sometimes it may be more convenient to transform the automatic frameticks data:

 rp = RegionPlot[x^2 + y^3 < 2 && x + y < 1, {x, -2, 2}, {y, -2, 2}, 
 FrameTicks -> Automatic]

region plot with wick labels

First extract the frameticks information and change the labels to blank:

 newticks = Last@First[AbsoluteOptions[rp, FrameTicks]];
 newticks[[All, All, 2]] = "";

Then replot or useShow with the new frameticks:

 Show[rp, FrameTicks -> newticks]

to get:

region plot with no tick labels

share|improve this answer
1  
I think this solution has the potential to be the best, but it leaves space at the top and bottom of the plot. I propose: newticks[[All, All, 2]] = Spacer[0]; –  Mr.Wizard Feb 21 '12 at 7:06
    
@Mr.Wizard, thank you! I thought an advantage of this approach was that one could choose the string length of the label by using a blank string of desired length " ". But using Spacer[k] gives more precise control. –  kguler Feb 21 '12 at 7:42
    
You're welcome. I noticed that, rather surprisingly, the ticks change somewhat between your first and second plots. I added an answer that is a bit of a cheat, but it preserves the default ticks if that is desired. –  Mr.Wizard Feb 21 '12 at 7:49
1  
When I create my plots I rather specify the ImageSize and set AspectRatio to Full in that way then I can specify my ImagePadding to correctly position my plot. I like your answer since it removes the unwanted data instead of just hiding it by making it transparent. The problem I have now is that I cannot extract the ticks marks because it wants the AspectRatio to be something other than Full. Any ideas how to deal with this? –  jmlopez Apr 9 '13 at 18:38

FrameTicks

Consider FrameTicks in the example below:

RegionPlot[Sin[x] Sin[y] > 1/4, {x, -1, 1}, {y, -1, 1},
  FrameTicks -> {Table[{k, "", {If[Mod[k, .5] == 0, .02, .01], 0}}, {k, -1, 1, .1}], 
                 Table[{k, "", {If[Mod[k, .5] == 0, .02, .01], 0}}, {k, -1, 1, .2}]}]

FrameTicks

In Table[{k, "", {If[Mod[k, .5] == 0, .02, .01], 0}}, {k, -1, 1, .1}] ,

k is the location of the tick

"" is the label

If... determines whether to use a major (.02) or minor (.01) tick on the inside of the respective axis.

0 indicates that the tick should not appear on the outside of the axis.

Note that the first Table sets the horizontal edges of the frame (with ticks every .1 units); the second Table sets the vertical edges of the frame (with ticks every .2 units).

share|improve this answer

I don't believe this has been mentioned yet:

RegionPlot[1 < Abs[x + I y] < 2, {x, -2, 2}, {y, -2, 2}, ImagePadding -> 1]

Mathematica graphics

ImagePadding
is an option for graphics functions that specifies what absolute extra padding should be left for extended objects such as thick lines and annotations such as tick and axis labels.

share|improve this answer
    
Why does this work? –  Eli Lansey Feb 21 '12 at 14:01
    
@Eli well, ImagePadding specifies the space around the graph outside of the Frame. Normally this is calculated to include the ticks and labels. I tried 0 but that cuts into the frame slightly, so 1 crops everything but the frame. –  Mr.Wizard Feb 21 '12 at 14:17
1  
It doesn't work when you have graphics outside the Frame (precisely because you're using ImagePadding). For example, Graphics[{Thickness[.3], Pink, Circle[]}, ImagePadding -> 1, Frame -> True] (remove ImagePadding to see how it ought to look) –  rm -rf Feb 21 '12 at 15:27
    
@R.M correct. I still like kguler's method because it actually removes the numbers rather than merely hiding them by one means or another. –  Mr.Wizard Feb 21 '12 at 21:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.