8

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.

kjo
  • 11,717
  • 1
  • 30
  • 89

1 Answers1

9

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.

Nasser
  • 143,286
  • 11
  • 154
  • 359