MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Fw: BarChart inside a Frame. How to remove Labels from the top of the frame? How to put x-axis label below and not on the side?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80637] Re: Fw: BarChart inside a Frame. How to remove Labels from the top of the frame? How to put x-axis label below and not on the side?
  • From: "Nasser Abbasi" <nma at 12000.org>
  • Date: Tue, 28 Aug 2007 02:01:42 -0400 (EDT)
  • References: <002f01c7e7f2$0bdca560$8fcc0544@computerh20djr> <fatghp$24i$1@smc.vnet.net>

"Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com> wrote in message 
news:fatghp$24i$1 at smc.vnet.net...
> [See my answer at the bottom of the post.]
>
> Nasser Abbasi  wrote:
>
>> Thanks Jean for your reply.
>>
>> I got a similar reply from Bob Hanlon below, but this solution does not 
>> work
>> really for the reasons I explained below. I posted this back to the
>> newsgroup (but this takes too long to show) so I am sending you the 
>> message
>> below.
>>
>> thank again for your time.
>>
>> Nasser
>>

>>
>> ----- Original Message -----
>> From: "Nasser Abbasi" <nma at 12000.org>
>> To: <mathgroup at smc.vnet.net>
>> Cc: <hanlonr at cox.net>
>> Sent: Sunday, August 26, 2007 5:01 AM
>> Subject: Re:  BarChart inside a Frame. How to remove Labels from
>> the top of the frame? How to put x-axis label below and not on the side?
>>
>>
>> >
>> >> ---- Nasser Abbasi <nma at 12000.org> wrote:
>> >>> Mathematica 6.0.1
>> >>>
>> >>> This is really annoying. I wanted a BarChart inside a frame. All 
>> >>> works
>> >>> ok,
>> >>> except it insists on putting the bar labels on top of the frame as 
>> >>> well
>> >>> as
>> >>> on the bottom of the frame, like this:
>> >>>
>> >>> BarChart[{1, 2, 3}, Frame -> True]
>> >>>
>> >>> I can remove the labels altogether, and use FrameTicks, but it still
>> >>> does it
>> >>> again !
>> >>>
>> >>> BarChart[{1, 2, 3}, Frame ->
>> >>> True,BarLabels->None,FrameTicks->{{1,2,3},{0,1}}]
>> >>>
>> >>> I think BarChart conflict with Frame somehow.
>> >>>
>> >>> The only reason I wanted to put the BarChart inside a frame, is that
>> >>> with a
>> >>> frame, when I put the x-label, it will go below and not on the side.
>> >>>
>> >>> I wanted to write a large x-label, and just using BarChart, the 
>> >>> x-label
>> >>> was
>> >>> extending too far to the right since it start at the right edge of 
>> >>> the
>> >>> axis,
>> >>> as you see from this example
>> >>>
>> >>> BarChart[{1, 2, 3}, AxesLabel -> {"x-axis label"}]
>> >>>
>> >>> Is there a way to solve this problem?  Either just use BarChart 
>> >>> without
>> >>> Frame, but tell it to put the x-label BELOW, or use a Frame with
>> >>> BarChart
>> >>> but not have the bar labels at top and bottom as well?
>> >>>
>> >
>> >
>> >> Needs["BarCharts`"];
>> >>
>> >> BarChart[{1, 2, 3},
>> >> Frame -> True, FrameTicks -> {Range[3], Range[0, 3], None, None},
>> >> FrameLabel -> (Style[#, FontSize -> 14] & /@ {"x-axis label",
>> >>     "y-axis label"})]
>> >>
>> >> BarChart[{1, 2, 3},
>> >> Frame -> {True, True, None, None},
>> >> FrameTicks -> {Range[3], Range[0, 3], None, None},
>> >> FrameLabel -> (Style[#, FontSize -> 14] & /@ {"x-axis label",
>> >>     "y-axis label"})]
>> >>
>> >>
>> >> Bob Hanlon
>> >>
>> >
>> > Thanks Bob,
>> >
>> > You solution helps, but now I am unable now to use BarLabels !
>> >
>> > I can't use FrameTicks in place of BarLabels, since FrameTicks do not 
>> > get
>> > positioned at the same locations as BarLabels.  Using Frame seems to
>> > prevent BarLabels from showing up:
>> >
>> > BarChart[{1, 2, 3}, Frame -> True, BarLabels -> {0, 1, 2},
>> >  FrameTicks -> {None, Range[0, 3], None, None},
>> >  FrameLabel -> (Style[#1, FontSize -> 14] & ) /@ {"x-axis label", 
>> > "y-axis
>> > label"}]
>> >
>> > For example, If I replace frameTicks for the x-axis with what I wanted 
>> > to
>> > be the BarLabels, I get this
>> >
>> > BarChart[{1, 2, 3}, Frame -> True, FrameTicks -> {{0, 1, 2}, Range[0, 
>> > 3],
>> > None, None},
>> >  FrameLabel -> (Style[#1, FontSize -> 14] & ) /@ {"x-axis label", 
>> > "y-axis
>> > label"}]
>> >
>> > and nothing I did would make FrameTicks {0,1,2} to be placed right 
>> > where
>> > the earlier frameTicks {1,2,3} were.
>> >
>> > ofcourse I can use BarLabels without the FrameTicks, but then we are 
>> > back
>> > to square one, the BarLabels would now show in the top and bottom:
>> >
>> > BarChart[{1, 2, 3}, Frame -> True, BarLabels -> {0, 1, 2},
>> >  FrameLabel -> (Style[#1, FontSize -> 14] & ) /@ {"x-axis label", 
>> > "y-axis
>> > label"}]
>
> Hi Nasser,
>
> This time, I believe that the following expression yields the result
> that you are looking for.
>
> Needs["BarCharts`"];
> BarChart[{1, 2, 3}, Frame -> {True, True, None, None},
>   FrameTicks -> {{{1, "0"}, {2, "1"}, {3, "2"}}, Range[0, 3], None,
>       None}, FrameLabel -> (Style[#1, FontSize -> 14] & ) /@
>       {"x-axis label", "y-axis label"}]
>
> So we get a bar chart with the bar labeled 0, 1 , and 2 on the x-axis
> and below a centered label for the axis. The trick is to use the form
> {tick_position, tick_label} for each ticks on the x-axis For instance,
> {2,"1"} tells Mathematica to display one rather than two for the
> second tick.
>
> Regards,
> -- 
> Jean-Marc
>

Thanks Jean (and to Bob as well). yes, this works great.

Nasser



  • Prev by Date: Re: Plot "not working"
  • Next by Date: Re: FWHM, InterpolationFunction & Solve
  • Previous by thread: Re: Fw: BarChart inside a Frame. How to remove Labels from the top of the frame? How to put x-axis label below and not on the side?
  • Next by thread: explanation of the evaluation properties of 2nd args of Block With & Module via example