Re: Non numerical x-axis in (Date)ListPlot?
- To: mathgroup at smc.vnet.net
- Subject: [mg78997] Re: [mg78986] Non numerical x-axis in (Date)ListPlot?
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 15 Jul 2007 01:08:08 -0400 (EDT)
- Reply-to: hanlonr at cox.net
The Sort included below is to cover the case when the data is not pre-sorted by labels
dat1 = {{"A1", 2}, {"A4", 1}, {"A2", 3}};
dat2 = {{"A1", 2.2}, {"A3", 0.5}, {"A2", 2.9}, {"A4", 1.1}};
xcoord = Union[Join @@ (#[[All, 1]] & /@ {dat1, dat2})];
dat = Sort /@ ({dat1, dat2} /.
{x_, y_?NumericQ} :>
{Position[xcoord, x][[1, 1]], y});
ListPlot[dat,
PlotJoined -> True,
Frame -> True,
FrameTicks -> {Thread[{Range[Length[xcoord]], xcoord}],
Automatic, None, None},
Epilog -> {AbsolutePointSize[4],
Thread[{{Blue, Red}, Map[Point, dat, {2}]}]}]
Bob Hanlon
---- Maarten van der Burgt <maarten.vanderburgt at icos.be> wrote:
> Dear all,
>
> I have two sets of data:
>
> dat1 = {{"A1",2},{"A2",3},{"A4",1}}
> dat2 = {{"A1",2.2},{"A2",2.9},{"A3",0.5},{"A4",1.1}}
>
> Is there a simple way I can plot these with the {"A1", "A2", "A3", "A4"} as
> equidistant tick marks/labels along the horizontal axis and a standard
> numerical vertical axis?
> Note the missing "A3" in dat1.
>
> I could not find anything in the options of ListPlot, or in the new (6.0)
> DateListPlot.
>
> Thanks for your help,
>
> Maarten van der Burgt
> Leuven, Belgium
>
>