2
$\begingroup$

I need to plot in Mathematica without labeling. For example, this code:

Plot[Sin[x], {x, 0, 6 Pi}, Frame -> True, Axes -> False, 
PlotRange -> {{0, 10}, {-2, 2}}]

produces this plot:

enter image description here

However, I need only figure and not the labeling of horizontal and vertical axis.

$\endgroup$
1
  • $\begingroup$ Related: (16749) (converse) $\endgroup$
    – Mr.Wizard
    Dec 5, 2014 at 21:52

3 Answers 3

3
$\begingroup$

If you want to keep the tick marks, then how about this:

Plot[Sin[x], {x, 0, 6 Pi}, Frame -> True, Axes -> False, 
 PlotRange -> {{0, 10}, {-2, 2}}, LabelStyle -> Opacity[0]]

labels gone

Here I used LabelStyle to make the labels transparent (even though they are still generated together with the ticks). Alternatively, you can manually specify the tick marks with empty labels, but I assume you want something that retains the automatic placement of the ticks.

Another approach:

There's also this method, using the ImagePadding option:

Plot[Sin[x], {x, 0, 6 Pi}, Frame -> True, Axes -> False, 
 PlotRange -> {{0, 10}, {-2, 2}}, ImagePadding -> 1]

labels gone

What this does is to make the border around the frame defined by the PlotRange so thin that there isn't enough room to display any of the tick labels. I just have to make sure that there is enough padding to show the frame, that's why the value 0 doesn't work.

$\endgroup$
0
4
$\begingroup$

You can (mis)use FrameTicksStyle:

Plot[Sin[x], {x, 0, 6 Pi}, Frame -> True, Axes -> False, 
 PlotRange -> {{0, 10}, {-2, 2}}, 
 FrameTicksStyle -> Directive[FontOpacity -> 0, FontSize -> 0]]

enter image description here

$\endgroup$
2
  • $\begingroup$ It was also a helpful answer. thanks a lot $\endgroup$
    – zenith
    Dec 9, 2014 at 10:28
  • $\begingroup$ @zenith You're most welcome, thanks for the positive feedback! $\endgroup$
    – user9660
    Dec 9, 2014 at 17:01
3
$\begingroup$
 Plot[Sin[x], {x, 0, 6 Pi}, Frame -> True, Axes -> False, 
 PlotRange -> {{0, 10}, {-2, 2}},
 FrameTicksStyle -> {{{0.1}, None}, {0.1, None}}]
$\endgroup$
4
  • $\begingroup$ You're removing the labels AND the tick marks $\endgroup$ Dec 5, 2014 at 18:08
  • $\begingroup$ no, i wanted to remove only labels. $\endgroup$
    – zenith
    Dec 5, 2014 at 23:45
  • $\begingroup$ Try running the code. $\endgroup$ Dec 5, 2014 at 23:47
  • $\begingroup$ this code also produced desired results but i observed some extra dots. thanks for the help $\endgroup$
    – zenith
    Dec 9, 2014 at 10:29

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