Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #1413
| From | Hermann Peifer <peifer@gmx.eu> |
|---|---|
| Newsgroups | comp.graphics.apps.gnuplot |
| Subject | Re: Histogram for irregular data |
| Date | 2012-10-17 06:25 -0300 |
| Organization | albasani.net |
| Message-ID | <507E7989.1050103@gmx.eu> (permalink) |
| References | <d9ed0216-4304-4121-9baf-cdb636d4d579@googlegroups.com> |
On 2012-10-17 3:38, schickb@gmail.com wrote:
> I'd like to create a histogram for data with "unknown" numbers of entires for each box. Further, I'd like to be able to specify the target box using the first column of data. For example the original data might look like:
>
> WA 1
> IL 2
> OH 3
> WA 2
> WA 1
> OH 1
>
> The resulting histogram should have 3 boxes with x labels of: WA, IL, OH. WA would be a box with 3 segments (1, 2, 1), IL a box with 1 segment (2), and OH a box with 2 segments (3, 1).
>
> Is this possible out of the box with gnuplot? If not, I could post process the data into a format like:
>
> WA 1 2 1
> OH 3 1 0
> IL 2 0 0
>
> But that's a bit ugly since I'll have to process the entire data file before writing a single line since the number of entires for a box is unknown to start with.
>
With a reasonable data file size, I would pre-process the data on the
fly, perhaps in this way:
plot "<( awk '{a[$1]=a[$1] FS $2}END{for (i in a) print i, a[i]}' file
)" using ...
The above AWK one-liner prints your sample data like this:
IL 2
OH 3 1
WA 1 2 1
Hermann
Back to comp.graphics.apps.gnuplot | Previous | Next — Previous in thread | Next in thread | Find similar
Histogram for irregular data schickb@gmail.com - 2012-10-16 23:38 -0700
Re: Histogram for irregular data Hermann Peifer <peifer@gmx.eu> - 2012-10-17 06:25 -0300
Re: Histogram for irregular data schickb@gmail.com - 2012-10-17 09:12 -0700
Re: Histogram for irregular data Hermann Peifer <peifer@gmx.eu> - 2012-10-17 21:45 -0300
Re: Histogram for irregular data schickb@gmail.com - 2012-10-17 18:01 -0700
Re: Histogram for irregular data sfeam <sfeam@users.sourceforge.net> - 2012-10-17 23:24 -0700
Re: Histogram for irregular data schickb@gmail.com - 2012-10-19 09:05 -0700
csiph-web