Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ListLinePlot Labels

228 views
Skip to first unread message

Eddie Fonner

unread,
Jan 29, 2010, 7:48:23 AM1/29/10
to
I'm trying to create a ListLinePlot with custom labels on the x-axis, i.e. "January, February..." instead of "1, 2..."

The ChartLabels option doesn't seem to be compatible with ListLinePlot. Do you guys have any other suggestions, or possibly a way of hacking this with AxesLabel?

Jaebum Jung

unread,
Jan 30, 2010, 7:11:58 AM1/30/10
to
Do you mean this?

ListLinePlot[Prime[Range[12]],Filling->Axis,Ticks->{{#,DateString[{1,#},"MonthNameShort"]}&/@Range[1,12],Automatic}]

- Jaebum

Chris Degnen

unread,
Jan 30, 2010, 7:13:05 AM1/30/10
to
You could try this:

(* Adapting the documented ListLinePlot example *)
Print[ListLinePlot[Prime[Range[16]], Filling -> Axis]];
x = Range[16];
y = Prime[x];
x2 = {2010, #, 1} & /@ x;
Print[DateListPlot[Transpose[{x2, y}],
Joined -> True, Filling -> Axis,
DateTicksFormat -> "MonthNameShort"]];

Patrick Scheibe

unread,
Jan 30, 2010, 7:13:27 AM1/30/10
to
Hi,

no hack. Just create your ticks or use a tick-function.

data = Table[{i, RandomReal[]}, {i, 1, 12}];
ticks[min_, max_] :=
Table[{i,
Rotate[#, Pi/2] &@
Style[DateString[DateList[{1990, i, 1, 0, 0, 0}], "MonthName"],
Blue,
FontFamily -> "Helvetica"]}, {i, Floor[min], Ceiling[max]}];
ListLinePlot[data, Ticks -> {ticks, Automatic}]

Cheers
Patrick

PS: and AxesLabel is something different.

Tomas Garza

unread,
Jan 30, 2010, 7:13:59 AM1/30/10
to
One possibility is "hacking" this with Ticks. Full length month names will
make the x-axis appear a little cluttered, but you can Rotate them to produce a more pleasant result:

data=2 Range[12];

months={"January","February","March","April","May","June","July","August","September","October","November","December"};

tks=Transpose@{Range[12],Rotate[#,Pi/4]&/@months};

ListLinePlot[data,Ticks->{tks,Automatic}];

Tomas

> Date: Fri, 29 Jan 2010 07:48:29 -0500
> From: efo...@armus.com
> Subject: ListLinePlot Labels
> To: math...@smc.vnet.net
>
> I'm trying to create a ListLinePlot with custom labels on the x-axis, i.e. "January, February..." instead of "1, 2..."

Chris Degnen

unread,
Jan 30, 2010, 7:30:54 AM1/30/10
to
Alternatively:

(* Adapting the documented ListLinePLot example *)
ListLinePlot[Prime[Range[16]], Filling -> Axis, Frame -> True,
FrameTicks -> {{{1, "Jan"}, {4, "Feb"}, {7, "Mar"}, {10, "Apr"},
{13, "May"}, {16, "Jun"}}, Automatic, None, None}]

Bob Hanlon

unread,
Jan 31, 2010, 5:59:29 AM1/31/10
to

data = RandomReal[{10, 100}, {12}];

DateListPlot[data, {2009, 1},
Joined -> True]

ListLinePlot[data,
Frame -> True,
Axes -> False,
PlotRange -> {{.8, 12.2}, All},
FrameTicks -> {
{Automatic, Automatic},
{Join[{#, ""} & /@ Range[12], {{1, "Jan"}, {4, "Apr"},
{7, "Jul"}, {10, "Oct"}}],
{#, ""} & /@ Range[12]}},
GridLines -> {{#, GrayLevel[.85]} & /@ Range[4, 10, 3], None}]


Bob Hanlon

---- Eddie Fonner <efo...@armus.com> wrote:

=============


I'm trying to create a ListLinePlot with custom labels on the x-axis, i.e. "January, February..." instead of "1, 2..."

The ChartLabels option doesn't seem to be compatible with ListLinePlot. Do you guys have any other suggestions, or possibly a way of hacking this with AxesLabel?


--

Bob Hanlon


0 new messages