MathGroup Archive 2007

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

Search the Archive

Re: Non numerical x-axis in (Date)ListPlot?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79004] Re: Non numerical x-axis in (Date)ListPlot?
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sun, 15 Jul 2007 01:11:54 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <f79s2b$54b$1@smc.vnet.net>

Maarten van der Burgt 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.

I am afraid that you will have to massage your data by hand or more or 
less automatically depending on the real structure of your data. In the 
example below, first we change the text values into numerical values, 
and tell explicitly where, and with which label, each tick mark must be 
drawn.

dat1 = {{"A1", 2}, {"A2", 3}, {"A4", 1}};
dat2 = {{"A1", 2.2}, {"A2", 2.9}, {"A3", 0.5}, {"A4", 1.1}};
ListPlot[
    {dat1, dat2} /. {"A1" -> 1, "A2" -> 2, "A3" -> 3, "A4" -> 4},
    AxesOrigin -> {0, 0},
    Ticks -> {{{1, "A1"}, {2, "A2"}, {3, "A3"}, {4, "A4"}}, Automatic},
    PlotStyle ->
        {Directive[Red, AbsolutePointSize[5]],
         Directive[Blue, AbsolutePointSize[5]]}]

Regards,
Jean-Marc

> Thanks for your help,
> 
> Maarten van der Burgt
> Leuven, Belgium


  • Prev by Date: RE: Non numerical x-axis in (Date)ListPlot?
  • Next by Date: Re: slideshow presentation in Notebook format
  • Previous by thread: Re: Non numerical x-axis in (Date)ListPlot?
  • Next by thread: Re: Re: Non numerical x-axis in (Date)ListPlot?