8
$\begingroup$

This question already has an answer here:

I have the following:

Graphics[
  {
   EdgeForm[Opacity[0.5]],
   Opacity[0.75],
   ColorData[24, 6],
   Disk[{1, 0.5}, {1, 0.5}]
  },
  Frame -> True,
  PlotRangePadding -> 0.5,
  ImagePadding -> 30
 ]

Mathematica graphics

I want to change the tick labels so that they occur only at whole-number values, and have no fractional part (i.e. 0, 1, 2,... rather than 0.0, 1.0, 2.0).

I want to keep everything else, including the tick marks, exactly as it is now.

Is there a way to do this that does not require me to build the unlabeled tick marks1 from scratch?


1 The "unlabeled tick marks" would be: 1) all the minor ticks; 2) all the major ticks on the top and right edges of the frame; 3) the major ticks at (-0.5, 0.5) on the left edge, and at (0.5, -0.5) and (1.5, -0.5) on the bottom edge.

$\endgroup$

marked as duplicate by Michael E2, MarcoB, m_goldberg, Bob Hanlon, Mr.Wizard Jul 2 '15 at 11:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    $\begingroup$ The way to do it without rebuilding the ticks from scratch would be to use AbsoluteOptions or FullGraphics, but those functions have never worked properly and have become more broken with each new version of Mathematica. $\endgroup$ – Simon Rochester Jun 29 '15 at 5:10
  • 1
    $\begingroup$ Related: (6043), (6851), (19123), (76228), (85339), (87095). The bug that makes this more difficult: (68937) $\endgroup$ – Mr.Wizard Jul 1 '15 at 14:38
7
$\begingroup$

Will this work for you?

Mathematica graphics

fticks[min_, max_] := 
 Table[If[FractionalPart[i] == 0., {i, Round@i, 0.02}, {i, ""}], {i, 
   Floor[min], Ceiling[max], 0.1}]

Graphics[{EdgeForm[Opacity[0.5]], Opacity[0.75], ColorData[24, 6], 
  Disk[{1, 0.5}, {1, 0.5}]}, Frame -> True, PlotRangePadding -> 0.5, 
 ImagePadding -> 30,
 FrameTicks -> {{Automatic, Automatic}, {fticks, Automatic}}]

reference How to increase the number of minor ticks in a plot?

I do not know how to do it without calling custom function to build the tick labels.

$\endgroup$

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