MathGroup Archive 2003

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

Search the Archive

Re: Data Plotting With Less Typing

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45330] Re: Data Plotting With Less Typing
  • From: Tom Burton <tburton at brahea.com>
  • Date: Wed, 31 Dec 2003 03:23:38 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Here's how I would do it. Let's start with some data resembling your
example:

In[22]:=
TableForm[data = Table[Random[], {15}, {5}]]
Out[22]//TableForm=
0.15595     0.942249     0.961393   0.900761   0.0209591
0.315649    0.251274     0.361697   0.274237   0.904032
0.672945    0.484144     0.710673   0.834083   0.297317
0.650061    0.437515     0.33732    0.814028   0.0773414
0.876904    0.299412     0.609062   0.757582   0.720954
0.357162    0.647669     0.856821   0.699995   0.0415138
0.396395    0.495124     0.425758   0.137481   0.72345
0.0109795   0.715085     0.303398   0.426133   0.360919
0.27757     0.966077     0.612105   0.283577   0.400666
0.666666    0.00304337   0.525995   0.679712   0.309503
0.355374    0.669174     0.979717   0.267989   0.958979
0.17405     0.553959     0.130508   0.23553    0.163071
0.838874    0.82711      0.809397   0.802152   0.561304
0.861033    0.197291     0.518575   0.160638   0.194367
0.194248    0.99258      0.480926   0.884864   0.838874

I've omitted the header row. If you have already dataH including the header
row, you can drop it with the expression data=Rest[dataH]. Note (since you
are new) that I apply TableForm AFTER setting data. Beware of //TableForm,
because the postfix operator "//" will not reach past an equal sign. Next,
grab the qualifying data and form the samples to be plotted:

In[23]:=
samples = Cases[data,
    {a_, b_, c1_, c2_, d_} /; d > c2 ->
    Sin[a/b] + c1]
Out[23]=
{1.31262, 1.14353, 0.895485, 1.48617, -0.42144}

where "/;" is read "such that" and the rest is intuitive, I hope. The dummy
symbols a, b, etc. above are arbitrary.  I chose them to mimic your header
row. Now load the package containing the histogram function (you can find it
easily by looking up Histogram in the Master Index) and then plot:

In[24]:=
<< "Graphics`Graphics`"

In[25]:=
Histogram[samples];

Tom Burton

On 12/29/03 11:50 PM, in article bsrho9$qio$1 at smc.vnet.net, "Steve
Eichblatt" <steveeichblatt at yahoo.com> wrote:

> My data looks like this
> 
> {{"a", "b", "c1", "c2", "d"},
> {1.64657, 3.11775, 4.4374, 8.93891, 1.19198},
> {5.5366,  3.5689, 1.32583, 2.6293, 2.38973},
> {9.03042, 9.87567, 4.34064, 8.09357, 3.44279},
> {5.43228, 4.7836, 8.12985, 3.94991, 2.15411},
> etc.
> }
> 
> Where the first element contains the column headers and the rest is the
> data. Now i want to plot a histogram of, say, Sin[a/b]+c1 where d>c2 or
> some crazy thing.


  • Prev by Date: Re: Data Plotting With Less Typing
  • Previous by thread: Re: Data Plotting With Less Typing
  • Next by thread: RE: Re: Laplacian and curlcurl with maxwells eqn's