Way to limit xtics in histogram

  • Permalink
  • submit to reddit
  • Email
  • Follow


Gnuplot does not automaticly limit the amount of xticlabels in
histograms like it does with other plotting types.
To illustrate the problem:
http://shiona.ath.cx/count.png
I guess there are 61 xtics, maybe one of five could be ok.
Any help appreciated.

(Because some of you might possibly request the script, here it is:

set boxwidth 0.75 absolute
set style fill solid 1.00 border -1
set style data histogram
set style histogram cluster gap 1
set xtics nomirror out rotate by -30;

set title "Daily number of packages received from node \n \
during 18.11.2009 - 18.1.2009"

plot "ready/count" using 2:xtic(1) t '1978', \
     "ready/count" using 3 t '2473'

)
0
Reply Juho 1/20/2010 11:59:52 AM

See related articles to this posting


Juho Jokelainen wrote:

> Gnuplot does not automaticly limit the amount of xticlabels in
> histograms like it does with other plotting types.
> To illustrate the problem:
> http://shiona.ath.cx/count.png
> I guess there are 61 xtics, maybe one of five could be ok.
> Any help appreciated.

The form xtic(1) is shorthand for xtic(stringcolumn(1)).
That is, xtic(foo) really expects a function foo that returns a string. 

The command xtic(1) is doing exactly what you asked, which is to
place an tic label for every entry in column 1. So you need to do
something slightly different.  The basic idea should be evident
from this command:

  everyfifth(col) = (int(column(col) % 5 == 0) ? "A" : ""
  plot 'data' using 1:2:(everyfifth(0))

The function everyfifth(0) returns a string value for each point
in the data set.  Column 0 by convention holds the index of that
point within the data set. The string is set to "A" for every
5th point, and "" otherwise.

But you don't want "A". You want the contents of column 1,
treated as a string.  So we change this to

  everyfifth(col) = (int(column(col)) % 5 == 0) ? stringcolumn(1) : "") 


        Ethan

> 
> (Because some of you might possibly request the script, here it is:
> 
> set boxwidth 0.75 absolute
> set style fill solid 1.00 border -1
> set style data histogram
> set style histogram cluster gap 1
> set xtics nomirror out rotate by -30;
> 
> set title "Daily number of packages received from node \n \
> during 18.11.2009 - 18.1.2009"
> 
> plot "ready/count" using 2:xtic(1) t '1978', \
>      "ready/count" using 3 t '2473'
> 
> )

0
Reply sfeam 1/20/2010 8:23:27 PM

> The command xtic(1) is doing exactly what you asked, which is to
> place an tic label for every entry in column 1. So you need to do
> something slightly different. =A0The basic idea should be evident
> from this command:
>
> =A0 everyfifth(col) =3D (int(column(col) % 5 =3D=3D 0) ? "A" : ""
> =A0 plot 'data' using 1:2:(everyfifth(0))
>
Thanks.
I was thinking that I'd propably need some kind of if-block there but
didn't know the syntax.
I also thought that there is "set xtics start, frequency" but that
doesn't seem to work for strings.
But yeah, this should get my work done, thanks again.
0
Reply Juho 1/21/2010 1:42:04 AM

On Jan 21, 9:42=A0am, Juho Jokelainen <juho.jokelai...@gmail.com> wrote:
> > The command xtic(1) is doing exactly what you asked, which is to
> > place an tic label for every entry in column 1. So you need to do
> > something slightly different. =A0The basic idea should be evident
> > from this command:
>
> > =A0 everyfifth(col) =3D (int(column(col) % 5 =3D=3D 0) ? "A" : ""
> > =A0 plot 'data' using 1:2:(everyfifth(0))
>
> Thanks.
> I was thinking that I'd propably need some kind of if-block there but
> didn't know the syntax.
> I also thought that there is "set xtics start, frequency" but that
> doesn't seem to work for strings.
> But yeah, this should get my work done, thanks again.


Hi,
I have incorprated this solution into my gnuplot script.  But it
failed to generate histogram graph.
Could someone help me? Thanks.

My Data file (hist.txt):

bin distibution
0.100000 0.000000
0.200000 0.003273
0.300000 0.000818
0.400000 0.000818
0.500000 0.001637
0.600000 0.004092
0.700000 0.000818
0.800000 0.001637
0.900000 0.000818
1.000000 0.001637
1.100000 0.000000
1.200000 0.000000
1.300000 0.001637
1.400000 0.000818
1.500000 0.000818
1.600000 0.000818
1.700000 0.001637
1.800000 0.000000
1.900000 0.000000
2.000000 0.004910
2.100000 0.007365

My Gnuplot Script (bin_hist_gp.txt):
set xlabel "Bin Size "
set ylabel "Density "
unset key
set size 1.0, 1.0
set origin 0.0, 0.0
set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.75
set t png size 400,300
everytenth(col) =3D (int(column(col))%10 =3D=3D0)?stringcolumn(1):""
plot "hist.txt" u 2:(everytenth(0)) title "Distribution"
set output
exit

And the final output message after it is executed in gnuplot.
"
gnuplot bin_hist_gp.txt

plot "hist.txt" u 2:(everytenth(0)) title "Distribution"
                                                         ^
"bin_hist_gp.txt", line 12: Too many columns in using specification

"

And when I replace the code 'plot "hist.txt" u 2:(everytenth(0)) title
"Distribution" ' as ' plot "hist.txt" u 2:xticlabels(everytenth(0))
title "Distribution"  '.  It failed with unrecognized message.   I
have no idea about the real issue.
0
Reply GB2312 3/8/2010 7:05:59 AM

Am Montag, 8. M=C3=A4rz 2010 08:05:59 UTC+1 schrieb =E5=99=9C=E5=99=9C=E8=
=80=81=E5=85=AC:
> On Jan 21, 9:42=C2=A0am, Juho Jokelainen <juho.jokelai...@gmail.com> wrot=
e:
> > > The command xtic(1) is doing exactly what you asked, which is to
> > > place an tic label for every entry in column 1. So you need to do
> > > something slightly different. =C2=A0The basic idea should be evident
> > > from this command:
> >
> > > =C2=A0 everyfifth(col) =3D (int(column(col) % 5 =3D=3D 0) ? "A" : ""
> > > =C2=A0 plot 'data' using 1:2:(everyfifth(0))
> >
> > Thanks.
> > I was thinking that I'd propably need some kind of if-block there but
> > didn't know the syntax.
> > I also thought that there is "set xtics start, frequency" but that
> > doesn't seem to work for strings.
> > But yeah, this should get my work done, thanks again.
>=20
>=20
> Hi,
> I have incorprated this solution into my gnuplot script.  But it
> failed to generate histogram graph.
> Could someone help me? Thanks.
>=20
> My Data file (hist.txt):
>=20
> bin distibution
> 0.100000 0.000000
> 0.200000 0.003273
> 0.300000 0.000818
> 0.400000 0.000818
> 0.500000 0.001637
> 0.600000 0.004092
> 0.700000 0.000818
> 0.800000 0.001637
> 0.900000 0.000818
> 1.000000 0.001637
> 1.100000 0.000000
> 1.200000 0.000000
> 1.300000 0.001637
> 1.400000 0.000818
> 1.500000 0.000818
> 1.600000 0.000818
> 1.700000 0.001637
> 1.800000 0.000000
> 1.900000 0.000000
> 2.000000 0.004910
> 2.100000 0.007365
>=20
> My Gnuplot Script (bin_hist_gp.txt):
> set xlabel "Bin Size "
> set ylabel "Density "
> unset key
> set size 1.0, 1.0
> set origin 0.0, 0.0
> set style data histogram
> set style histogram cluster gap 1
> set style fill solid border -1
> set boxwidth 0.75
> set t png size 400,300
> everytenth(col) =3D (int(column(col))%10 =3D=3D0)?stringcolumn(1):""
> plot "hist.txt" u 2:(everytenth(0)) title "Distribution"
> set output
> exit
>=20
> And the final output message after it is executed in gnuplot.
> "
> gnuplot bin_hist_gp.txt
>=20
> plot "hist.txt" u 2:(everytenth(0)) title "Distribution"
>                                                          ^
> "bin_hist_gp.txt", line 12: Too many columns in using specification
>=20
> "
>=20
> And when I replace the code 'plot "hist.txt" u 2:(everytenth(0)) title
> "Distribution" ' as ' plot "hist.txt" u 2:xticlabels(everytenth(0))
> title "Distribution"  '.  It failed with unrecognized message.   I
> have no idea about the real issue.

Because this thread is nearly the only one I found while searching the web =
I will post my improved solution of every... here:

everyNth(countColumn,labelColumnNum,N) =3D((int(column(countColumn)) % N =
=3D=3D 0) ? stringcolumn(labelColumnNum) : "");

and you have to use it this way:

plot ... u 1:xtic(everyNth($2,2,10))
0
Reply diru91 9/26/2012 8:28:01 AM

Is it possible that there is a syntax error in the code you have provided?
0
Reply tommy 1/24/2014 12:35:52 AM

Am 24.01.2014 01:35, schrieb tommy.carstensen@gmail.com:
> Is it possible that there is a syntax error in the code you have provided?
> 

This is a newsgroup, dude, you have to quote the old posting.

I should sue google for stealing my old newspost and pretending i took
part in some "googlegroup". :-[
0
Reply Karl 1/24/2014 1:48:47 PM

On Wednesday, September 26, 2012 4:28:01 AM UTC-4, dir...@googlemail.com wrote:
> Because this thread is nearly the only one I found while searching the web I will post my improved solution of every... here:

Here's a complete, stand-alone, runnable script:

#!/bin/sh

# Generate the input data file.  Columns are:
# 1 datapoint identifier
# 2 Y value
# 3 xtic labels
perl -e 'for(500..600) {
  printf "%d\t%.1f\t\"Foo %d\"\n",$_,rand($_)/10,$_
}
' >in.dat

gnuplot <<EOF
set term png size 1800, 1000
set xtics rotate by -90

nth(countCol,labelCol,n) = \
  ((int(column(countCol)) % n == 0) ? stringcolumn(labelCol) : "")

set output "out.png"
plot \
"in.dat" using 1:2:xtic(nth(1,3,10)) with linespoints \
   pointtype 2 linecolor rgb "red"
EOF

display out.png &
0
Reply waxrat 6/16/2014 3:45:54 PM

Am 16.06.2014 17:45, schrieb waxrat@gmail.com:
> On Wednesday, September 26, 2012 4:28:01 AM UTC-4, dir...@googlemail.com wrote:
>> Because this thread is nearly the only one I found while searching the web I will post my improved solution of every... here:
> 
> Here's a complete, stand-alone, runnable script:
> 

It�d still be great if you gave everybody else here some context for
this. ;-)

People who use their newsreader instead of googlegroups don�t have the
previous posts directly at hand if they�re older than a few months or so.

 K



0
Reply Karl 6/16/2014 4:28:43 PM
comp.graphics.apps.gnuplot 4816 articles. 0 followers. Post

8 Replies
1566 Views

Similar Articles

[PageSpeed] 26


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

how do I limit math output to say 2 digits like 2.33? I found way called precision setting but is that the right way?
curious On 7/5/12 3:41 PM, quiet_lad wrote: > curious Man format -- +------------------------------------------------------------------------+ | Gerald W. Lester, President, KNG Consulting LLC | | Email: Gerald.Lester@kng-consulting.net | +------------------------------------------------------------------------+ On 2012-07-05 22:41, quiet_lad wrote: > curious As Gerald points out, the proper way is the format command. I assume you are referring in the title to tcl_precision, but note that that is a leftov...

Seven-Way Comparative Histogram
I have one dependent variable (final) and seven independent variables. data math; input final art syart attend elm quiz tutor conf; cards; x x x x x x x x x x x x x x x x x x x x x ; How can I create a seven way comparative histogram. May I put them as starndardized scores insead to put them in a Seven-way comparative histogram? If so, how do I code for that? thx ...

Best/better way? (histogram)
Hello, I've got several versions of code to here to generate a histogram-esque structure from rows in a CSV file. The basic approach is to use a Dict as a bucket collection to count instances of data items. Other than the try/except(KeyError) idiom for dealing with new bucket names, which I don't like as it desribes the initial state of a KeyValue _after_ you've just described what to do with the existing value, I've come up with a few other methods. What seems like to most resonable approuch? Do you have any other ideas? Is the try/except(KeyError) idiom reallyteh best? I...

Please help with xtic on histogram!
Hello, I am trying to read xtic labels from data file for histogram chart. On X axis I need labels, from the last, 5-th column of my data file (see bellow). These labels have the form '[x1,x2..xN] such as [1,2,3], etc. I am trying to use something like: plot "t1dat.txt" u 2:xtic(5) t "Best Fit", "" u 3 t "In Class", "" u 4 t "Other" which does not show the labels. Thanks! === My data file: # Class BestFit InClass Other ClassName 1 34 - - [1,2,3] 2 - 36 - [3,1] 3 - 36 - [3,1,2] 4 - 35 - [3,1,2,3] 5 - 35 - [1,2...

A way around the limitations of Re[] and Im[]
As you know, Re[expr] and Im[expr] are left unevaluated when expr is not numeric. I had good luck in simple cases with the following substitution trick: Real[c_]:=c/.I->0; Imag[c_]:=(c-Real[c])/.I->1; Do you see any problem with these definitions? carlos@colorado.edu (Carlos Felippa) wrote in message news:<cjr8lg$opp$1@smc.vnet.net>... > As you know, Re[expr] and Im[expr] are left unevaluated when expr is > not numeric. I had good luck in simple cases with the following > substitution trick: > > Real[c_]:=c/.I->0; Im...

A way to limit the data path delay
Hello, I have a problem with apparently no issue. I use a V5 and I have a problem with the data path delay of a net. This net is used everywhere in my design and particulary in fixed blocs. The fanout is reduced to the maximum and I put a maxdelay constraint on it. The syntesis options are configured for speed. Anybody have an idea to reduce this delay ? Tk. LilacSkin wrote: > Hello, > > I have a problem with apparently no issue. > > I use a V5 and I have a problem with the data path delay of a net. > This net is used everywhere in my design and particulary in fixed &...

pthread_join(): any way to limit how long it waits for?
When a thread exits normally, I want to wait for it to exit, and perhaps pick up its status, with pthread_join(). Will there be a race condition if the thread hangs before exiting: will pthread_join() wait forever? Is there any sensible way to limit the time that pthread_join() waits for? -- Simon Elliott http://www.ctsn.co.uk Simon Elliott wrote: > When a thread exits normally, I want to wait for it to exit, and > perhaps pick up its status, with pthread_join(). > > Will there be a race condition if the thread hangs before exiting: will > pthread_join() wait forever? N...

Opteron 8-way glueless limit?
What's the cause of the 8-way glueless limit for Opteron? I ask because I found a 10-node graph with at most two hops between nodes and three arcs per node. A 10-CPU motherboard would be... better than 8! :). Also, Del, since you seem to know enough about HT to snipe at it, would you care to speculate on whether HT could get across two PC board connectors, assuming I can keep the link length down to something like 16 inches? I'm imagining 10 little boards, each with an Opteron, 4 DIMMs, and a little I/O, plugged into a motherboard/backplane. Iain McClatchie wrote: > I'm im...

listdir()
I want to build a program that does some archiving. We have several programs that have been dumping files into a folder (one folder) for some time now. I want to limit the number of files returned by listdir to avoid trying to build a list with tons of entries. I then want to move those files into a zip archive for the appropriate day/month. Is there any way to build a list of the first 1000 files or so in a folder? Running Python 2.4.2 on Win32 with Win32 extensions. Thanks. -Pete Schott Peter A. Schott <paschott@no.yahoo.spamm.com> writes: > Is there any way to build a list ...

A way to time-limit a program in C
Is there a simple way to limit the amount of time that a program (vfork()+execvp()) can run? i.e., can you do this: main thread: andreyvul wrote: > Is there a simple way to limit the amount of time that a program > (vfork()+execvp()) can run? > i.e., can you do this: > main thread: apropos limit or: man 2 setrlimit On Apr 8, 11:51 pm, Frank Mertens <fr...@cyblogic.de> wrote: > andreyvul wrote: > > Is there a simple way to limit the amount of time that a program > > (vfork()+execvp()) can run? > > i.e., can you do this: > > main thread:...

Any way to detect a wireless connection and limit it?
Hello, I am working on an Acc2003 app for my company. In the interest of reducing chances of corruption due to unstable network connectivity, I would like to either prevent users from running it through a wireless connection, or limit their use to read-only. I have absolutely no idea if this is possible, and if so, how. Is there any way from within Access to get the list of routers they are connecting through? Ideally, I'd like to keep a list of "accepted router names", pop up a message telling them the database isn't supported through their current connection, and direct ...

Rate limiting (old way and new)
Under the old way (using a "shaper#" pseudo-network-device), all one had to do was to attach it, set the desired speed/maximum bandwidth, then route the desired destination address(es) through it. The new way uses the "tc" program from the iproute2 package. I have searched for examples on how to do this with "tc" and have found some, but am still unclear. The manual page for "tc" doesn't seem to list all the permutations (or options) of the command, nor does it really explain what the different queueing disciplines are. I also don't fully fol...

Histogram without deliberately putting xtics ?
I have data which looks like the following: entry1 old_val1 new_val1 entry2 old_val2 new_val2 entry3 old_val3 new_val3 .... .... I would like to do a histogram (with old_val and new_val "clubbed' together for each entry. Is there an easy way I can do this directly with the plot command? (or should i have to put all the entry names in xtics? My only concern is that i have way too many of these "entries".) Also, i really don't care if it shows just numbers instead of entry names... (e.g. entry1 can be "1") Thanks In article <bb...

way to increase sm freeList.limit?
Hi, I need to increase sm free list limit number. This value is 29, and I don't know how this value is determined. My setup is as follows: ***************************************** I have a master and one slave CPU on VME SM Backplane network. I make slave so busy that it cannot read sm packets, for test purposes and I see on master how free packets decrease and when no more free packets remains I see that smPktFreeGet called from smIfStartOutput returns NULL. -> smNetShow Anchor Local Addr: 0x4100 Sequential addressing enabled. Master address: 10.0.0.1 heartbeat = 17, header at 0x...

Is here a way to limit CPU Usage for a process
I am on Windows 2000 Server SP4. I have a batch process which could consume most of the CPU. Is there a way to limit the resources of this process, so it will not use more than 50% CPU. Prem Prem K Mehrotra wrote: > I am on Windows 2000 Server SP4. I have a batch process which could > consume most of the CPU. Is there a way to limit the resources of this > process, so it will not use more than 50% CPU. > > Prem It is probably all in the programming, depending on what commands/executables have been called to run, when to stop either before/after making the...

best way to limit data range
Hello, I'm plotting some data about spamassassin scores in our mail system, mostly real numbers between -30 and +60. For testing purposes I use sometime a spam trigger (a string you embed in a mail to trigger spamassassin response). This particular mail will score at 999.*. I don't want these "fake data" to appear on the plot. Is there a way to tell gnuplot to plot only values between -100 +100 but NOT having the X axis stuck with [-100,+100] range. I still want the X axis to autoscale in order to display the proper data range. I could sed, or grep the par...

Frequency multipliers: A way around Nyquist limitations?
I was wondering... Say I happen to have a 100MHz DAC around... if I had a perfect anti-imaging filter, I could get 50MHz of bandwidth from it, and with realistic filters I might get 40MHz. Say I take the filtered (analog) output from the DAC and feed it to a 4x frequency multiplier. Now my top frequency is something under 200MHz (perfect filters), or say 160MHz (realistic filters). Is this a viable techniques to increase the bandwidth of my system? Although a frequency mutliplier is non-linear (just a pair of cascaded mixers "mixing with themselves" for the 4x case), isn't t...

A way to time-limit a program in C #2
Is there a simple way to limit the amount of time that a program (vfork()+execvp()) can run? i.e., can you do this: unsigned timeout; main thread: ... pthread_create(.., p1, ...) pthread_create(..., p2, ...) pthread_join(p1) pthread_join(p2) p1: fd = open("foo", O_RDONLY) dup2(fd, 1) execvp("bar", ...) p2: time_t time_ = time if (time - _time >= timeout) pthread_kill(p1, 9) ...

set x axis limit and xtic in plotyy
Hi, Following is part of the code : [AX,H1,H2] = plotyy(x,y1,x,y2,'plot'); %set(gca,'xlim',[0 45]); %set(gca,'xtick',[0 15 30 45]); set(H1,'LineStyle','-','Color',[0,0,0]) set(H2,'LineStyle',':','Color',[0,0,0]) set(AX(1), 'YLim', [0 0.1]) set(AX(2), 'YLim', [20 40]) I'd like to set the x axis limit and xtick. However, if I uncomment the 2nd&3rd statements, it shows exact range of the figure but two different overlaid xtick numbers. Would somebody know what's wrong ? Thank you very much CH...

Efficient way to store a limited number of booleans
Hi, I was trying to make an entry in a std::map be stored more efficiently. The struct contained 3 booleans discribing it's property, so I am trying to make it as compact as possible. Using a std::vector<bool> in this case does not work, or at least is not as efficient for my particular case (size was 20 bytes). Same goes for tr1::array<bool,3>. Is there anything else that I could have reused ? Here is the current code: // Compact struct to store up to 8 booleans: struct B3 { template <unsigned int TPos> void SetB(bool v) { if( v ) b.b |= (...

FIT takes way too much time. How to limit ?
I am currently working with the FIT function to do unlinear fits of data. However I do experience from time to time that it more or less "iterate it self to death". Meaning it will never end.... This is a part of a bigger job and this is done automaticly so I guess the problem is that my x-data and y-data are not well suited for this FIT ? But how can I test if the FIT will work or not ? NOTE that I am not providing any startingpoints. That could perhaps also be a reason ? ...

Logging of rate-limited queries way too talkative
I'm trying RRL on the new BIND 9.9.4. When RRL steps in, if I understand the documentation properly, two things are logged, a summary of the beginning and end of RRL, and one message per rejected query (!) Since RRL is used when there is an attack, there are *many* such messages. Worse, the default behavior of BIND aggravates the attack by filling the disk. >From the ARM, I find no way to prevent these annoying messages, except shutting down all query errors logging. Here is my best config so far: logging { channel rrl_channel { file "rrl.log" versio...

Command line limit on WARP3: any way to increase?
Hello, I suiddenly started getting "nmake: fatal error U1095: expanded command line 'ilink -o:asl.exe version.obj ... nlmessages.obj /PM:VIO' too long while running on a project that expands the line to about 1300 characters (nmake and ilink are part of the VACPP 3.0 installation). What puzzles me is that I'm quite sure that few months ago I could run the "nmake" without problems on the same project with the same number of objects. I'm wondering what could I inadvertanly change during the last months... Running a test aside with just "dir <...

Is there a way to control or limit the size of cascaded windows?
Perhaps an odd question but as Ive recently stepped into the widescreen arena (Dell 2407 Wow!!) it has brought up a few questions. If I cascade windows they are approximately 4/5ths of the screen width - but on a 24" screen thats a bit too wide for my taste. So wondered if there's a way to set the default size of the window when using cascade? Also, does anyone know of keyboard shortcuts to cascade or tile or another way without having to find a gap on the task bar! Thanks for your time. Ian ...