16

I wanted to remove the Ticks in my coding but i can't. Here when i try to remove the Ticks the number also gone. I need numbers without Ticks, Ticks and GridLines should be automatic and don't usePlotRange .

BarChart[{{1, 2, 3}, {4, 5, 6}}, ImageSize -> 400, BarOrigin -> Left, 
          ChartLayout -> "Stacked", ImageSize -> {500, 300}, 
          GridLines -> {Automatic, None}, Ticks -> {{Automatic}, None}
          , 
          LabelStyle -> Directive[Opacity[1]], 
          TicksStyle -> Directive[Opacity[.3]]
          , 
          Axes -> {True, False}, AxesStyle -> Opacity[.0], 
          ChartStyle -> {RGBColor[.06, .29, .66], RGBColor[.01, .56, .61], 
                         RGBColor[1, .58, 0]},
          ChartBaseStyle -> EdgeForm[GrayLevel[.6]]]

enter image description here

Kuba
  • 136,707
  • 13
  • 279
  • 740
niren
  • 743
  • 4
  • 13

4 Answers4

11

Simply use option:

TicksStyle -> Directive[20, Opacity[0], FontOpacity -> 0.3]

Mathematica graphics

Credit to R.M for showing me FontOpacity.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
4

You could specify the Ticks manually, for example by

Ticks -> {Table[{i, i, 0}, {i, 0, 14, 2}], None},

The y axis stays without Ticks by the None the x axis gets at $i=0,2,...,14$ a Tick at $i$ with $i$ as label and zero ticks width.

Ronny
  • 1,141
  • 9
  • 17
  • No Ticks should be used because when i change value of BarChart the number have to change automatically based on values. – niren Dec 21 '12 at 12:03
  • You could adapt the Tableto the values the Ticks should be based on. E.g. if you have a min and a max and want to have num values Table[{i,i,0},{i,min,max,(max-min)/num}] – Ronny Dec 21 '12 at 12:06
  • Though I haven't had the possibility to check that here you may want to look at the CutomTicks package or this TickControl Code http://library.wolfram.com/infocenter/MathSource/5217 – Ronny Dec 21 '12 at 12:35
4

You can keep the numbers as they current show up but remove the ticks by specifying ticks as follows:

Ticks -> {Table[{2 i, 2 i, 0}, {i, 7}], None}

or

Ticks -> {Table[{2 i + 1, 2 i + 1, 0}, {i, 0, 8}], None}

(each tick is specified by a triplet {a,b,c}, with a corresponding to the location on the axis, b the label used, and c the length of the tick used - just set the length equal to 0).

Royce
  • 348
  • 1
  • 6
2

Due to AbsoluteOptions reporting Ticks and GridLines in an unuseable fashion, I've had to resort to Rasterizing to find out how many grid lines are automatically being produced.

data = {{1, 2, 3}, {4, 5, 6}};

bc = BarChart[data, ImageSize -> 400, BarOrigin -> Left, 
   ChartLayout -> "Stacked", ImageSize -> {500, 300}, 
   GridLines -> {Automatic, None}, Ticks -> {{Automatic}, None}, 
   LabelStyle -> 
    Directive[Bold, Opacity[1], Thick, Black, 
     FontFamily -> "Helvetica"], 
   TicksStyle -> Directive[20, Opacity[.3]], Axes -> {True, False}, 
   AxesStyle -> Opacity[.0], 
   ChartStyle -> {RGBColor[.06, .29, .66], RGBColor[.01, .56, .61], 
     RGBColor[1, .58, 0]}, ChartBaseStyle -> EdgeForm[GrayLevel[.6]]];

rbc = Rasterize[bc];
lines = Min[Last /@ Tally[rbc[[1, 1, -1]](* Top row of pixels *)]];
max = Max[Total /@ data];
interval = Quotient[max, (lines - 1)];
maxline = (lines - 1)*interval;
ticks = {Table[{i,(* Frame for padding *)Framed[ToString[i],
  FrameStyle -> None], 0}, {i, 0, maxline, interval}], None};

BarChart[data, ImageSize -> 400, BarOrigin -> Left, 
 ChartLayout -> "Stacked", ImageSize -> {500, 300}, 
 GridLines -> {Automatic, None}, Ticks -> ticks, 
 LabelStyle -> 
  Directive[Bold, Opacity[1], Thick, Black, 
   FontFamily -> "Helvetica"], 
 TicksStyle -> Directive[20, Opacity[.3]], Axes -> {True, False}, 
 AxesStyle -> Opacity[.0], 
 ChartStyle -> {RGBColor[.06, .29, .66], RGBColor[.01, .56, .61], 
   RGBColor[1, .58, 0]}, ChartBaseStyle -> EdgeForm[GrayLevel[.6]]]

enter image description here

Chris Degnen
  • 30,927
  • 2
  • 54
  • 108