Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #1413
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail |
|---|---|
| From | Hermann Peifer <peifer@gmx.eu> |
| Newsgroups | comp.graphics.apps.gnuplot |
| Subject | Re: Histogram for irregular data |
| Date | Wed, 17 Oct 2012 06:25:29 -0300 |
| Organization | albasani.net |
| Lines | 34 |
| Message-ID | <507E7989.1050103@gmx.eu> (permalink) |
| References | <d9ed0216-4304-4121-9baf-cdb636d4d579@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.albasani.net T2XJmrUKKUrHYW2JjTAfUyJO6mUrtN2QewfwnmdQ9QAeq5OutlCJQS6DSepCMDyzIBUcbMcPOWESI/0HborLpLaZmVU1jGfg7mxkc/gfwdWWCdekY7CiuxNtxZuB/6Aa |
| NNTP-Posting-Date | Wed, 17 Oct 2012 09:25:25 +0000 (UTC) |
| Injection-Info | news.albasani.net; logging-data="fn4H0qIwwT7MtJAt2shg6pSZNG2AvFggd0bdqH0kz+uOkclCTjnoGpO+0TuvtkuGzV1yMbwwmoXKC2FUvMtM1DZH0njZMXTFeIEQ93ugSqnEWyGly+y73LQ8T2G62vAM"; mail-complaints-to="abuse@albasani.net" |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 |
| To | schickb@gmail.com |
| In-Reply-To | <d9ed0216-4304-4121-9baf-cdb636d4d579@googlegroups.com> |
| Cancel-Lock | sha1:pZOmiwXnfyLzzHmUr8j+OfHjCbo= |
| Xref | csiph.com comp.graphics.apps.gnuplot:1413 |
Show key headers only | View raw
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