14
$\begingroup$

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

$\endgroup$
10
$\begingroup$

Simply use option:

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

Mathematica graphics

Credit to R.M for showing me FontOpacity.

$\endgroup$
4
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ No Ticks should be used because when i change value of BarChart the number have to change automatically based on values. $\endgroup$ – niren Dec 21 '12 at 12:03
  • $\begingroup$ 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}] $\endgroup$ – Ronny Dec 21 '12 at 12:06
  • $\begingroup$ Though I haven't had the possibility to check that here you may want to look at the CutomTicks package or this TickControl Code library.wolfram.com/infocenter/MathSource/5217 $\endgroup$ – Ronny Dec 21 '12 at 12:35
4
$\begingroup$

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).

$\endgroup$
2
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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