Way to limit xtics in histogram

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
Juho
1/20/2010 11:59:52 AM
comp.graphics.apps.gnuplot 4917 articles. 0 followers. Post Follow

8 Replies
1928 Views

Similar Articles

[PageSpeed] 19
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
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
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
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
diru91
9/26/2012 8:28:01 AM
Is it possible that there is a syntax error in the code you have provided?
0
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
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
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
Karl
6/16/2014 4:28:43 PM
Reply:
Similar Artilces:

there has to be a better way, or we are stuffed!
Company I work for has a SAN of about 50 TB. It is configured as 4 logical disks. So when there is a failure, that logical disk is out of action while the RAID rebuilds itself. "Hot swapping" doesn't help much when 1/4 of the system is paralysed for hours afterwards. It seems about once a month that one hard drive shits itself, and has to be replaced, triggering the fiasco again. Then system engineer says it would be good idea to run complete diagnostics. That means taking all offline for 172800 seconds = gazillions of dollars lost. On May 23, 6:55 pm, efff...@f-m....

Combo box problem... limit to list property
I have a combobox on an order form, that displays the names of organizations that we do business with (stored in "organization" table). On occassion, I would like to be able to enter an organization "on the fly".... an order for an organization that is a one time customer. My problem.. I can't reset the combobox limit to list property to "no". I get this error message: "Microsoft Access can't set the limittolist property to NO right now.. The first visible column, which is determined by the column width property, isnt equal to the bound column"...

ISELECT Limitations (mv.Enterprise)
Does the ISELECT command (on mv.Enterprise)have limitations in the number of operands that can be passed to it? I've created the indices required, but can't seem to make the combination of date ranges, customer numbers and part numbers execute properly. I receive this error message: [23] Invalid sentence: (followed by the command I've entered) Thanks in advance for any help or advice. Dave Morrison mve had probs with Indexed files as far as I remember. We tried to use it once too but found that firstly it wasn't exactly what it was professing to be, and secondl...

Best way to convert html to plain text in java?
Hello, I have a java servlet that processes plain text. I'd like to point to a specific url and pull over a webpage, then convert it to plain text for further processing. I have written some code that simply strips tags from the html, but this only does an OK job as it fails on poorly written html and javascript (to name a few). Are there any java APIs that would perform a better conversion? I've looked into JEditorPane and HTMLEditorKit, but haven't had any luck in getting these to perform the conversion. Thanks for any help! On Sun, 19 Mar 2006 08:20:01 +0100, <google@lrla...

Re: the best way to drop vars #5
Igor: The best way to drop (or keep) variables in SAS datasets is to stream them thru a SAS SQL view: proc sql; create view testVW as select var1,var2,var3,var4,var5,var6,var7,var8,var9,var10 from source ; quit; data test; set testVW; run; The SELECT list shows precisely the variables that you are streaming into a Data step. Further, you have the option to transform the variable values or rename the variables in the view, t0 subset rows in a dataset using a WHERE clause, and to combine data from more than one source. Sig -----Original Message----- From: SAS(r) Discussion [mailto:...

is there a way?
Is there any practical way to host multiple web sites when: 1) I have a single domain, 2) I have a dynamic IP assigned by RoadRunner, 3) I use ZoneEdit to WebForward because RR blocks 80 (DynSite keeps the IP updated), 4) I have W2K ISA as a proxy/firewall, 5) The web site(s) is(are) on W2K server (IIS 5.x, so I could create multiple sites based upon the header ... if there's some way to maintain uniqueness thru ZoneEdit)? "Stan" <sberry1.x@houston.rr.com> wrote in message news:NXUNc.59322$qa2.22581@fe2.texas.rr.com... > Is there any practical way to host multiple we...

Reasonable way to get graphics in a .pdf w/ long filenames?
in Mac OS X. I've been experimenting w/ this in PhotoShop CS and the best technique I've worked up thus far is to: - open all the files I want included - use the Contact Sheet II feature to make a file for each graphic w/ includes the filename (but it uses a strangely mid-numbered name if it's longer than 32 characters) - close every file except for the contact sheets - use the presentation creation feature to make a .pdf of all the open files Problems are the afore-mentioned mangling of long than 32 char filenames, and an utter inability to control the order in which the fi...

IIdb.org debates limitation?
Why is it that when I do a copy and paste from Word 98 (Mac) to the private message box all my styles vanish? I had some words bolded and that did not show on the paste. Is this normal or a limitation with Word 98? I seem to always have this problem with HTML forums when using older clients. I remember back when AOL had their own message boards in a non HTML format I could very easily copy and paste back and forth between ClarisWorks and still retain all the original formatting. John -- CERM-Church Education Resource Ministries http://johnw.freeshell.org/bible/ John 14:6 Jesus an...

Is there any way to vectorize this code...
Hi Can anyone help me in vectorizing this code.... M & N are the boundaries..... for theta = 0:pi/180:2*pi; x = cent_x + radius*sin(theta); y = cent_y - radius*cos(theta); if round(x) < N && round(x) > 1 && round(y) < M && round(y)>1 temp(round(x),round(y)) = 1; end end Thanks sbm wrote: > Hi > > Can anyone help me in vectorizing this code.... .... > if round(x) < N && round(x) > 1 && round(y) < M && round(y)>1 > temp(round(...

better way to do this in python
I have a file like this, cat file aaa bbb aaa aaa aaa awk '{x[$1]++}END { for (i in x) {print i,x[i]} } ' test bbb 1 aaa 4 I suppose I can do something like this. (pseudocode) d={} try: d[key]+=1 except KeyError: d[key]=1 I was wondering if there is a pythonic way of doing this? I plan on doing this many times for various files. Would the python collections class be sufficient? ...

Easiest way to read a XML doc from file, reformat it and write it indented to a second file?
Assume I have a XML docuemnt in file mydoc123.xml The XML doc is textually formatted as one long line/string without line breaks. Now I want to read this XML doc file into Java, then reformat it so that the hierarchy levels are indented in a human radble format "as usual". Finally the result should be written to another text file result.xml How can I do this most easily (preferable without third party libraries but only J2SE built-in functions)? Ray Raymond Schanks wrote: > Now I want to read this XML doc file into Java, then reformat it so > tha...

The easiest way to get free cash! #2
<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft DHTML Editing Control"> <TITLE></TITLE> </HEAD> <BODY> <P>Hi all,</P> <P>I became a member of an interesting free website that is totally unique. It actually rewards its members for learning! You can learn lots of important things and earn rewards taking fun quizzes, plus earn cash for other activities! Membership is free, and people of all ages and educational backgrounds everywhere can become members and participate at their own level. It�s ca...

a neat way of doing it?
Hi, I have monthly data of employee IDs . Column1 Ids for january 1985, Column2 Ids for February 1985 ...column 320 Ids for december 2004. Is their a neat way (instead of writing a whole program) of finding which employees are always in the sample for 2 consecutive years. In other words, for any consecutive 24 columns is their a function that would enable me to find the Ids that were always in each column? best Tamra intersect(). e.g. tmp=intersect(mtx(:,1),mtx(:,2)); for i=2:numCols, tmp=intersect(tmp,mtx(:,i)); end; ans=tmp; There is probably an easy way to vectorize this but this shou...

2 Dimensional Histogram
I have a 2 dimensional gray scale image (1024 * 1024 pixels).I want to plot a 2 dimensional histogram which shows how does the gray scale value varies spatially with the x and y dimensions. Please Let me know if any one has solved such problem. Thanks in advance. Amit Ailiani ...

What is the best way to rotate a JPG?
I've got several JPGs that I want to rotate 90 degrees. I believe that every time you save a JPG, there is some loss in quality, so would the best way to ensure the least amount of loss in quality be to set the JPG compression factor to 1 (lowest compression) when I save my rotated JPGs? Or is there a way to not lose any quality at all? In PSP8, 90 degree rotation is lossless. Open your PSP8 thumbnail browser, click once on one or more thumbnails, then right click. One of the options on the context menu is "JPG lossless rotation" <void@no.spam.com> wrote in message news...

Is there any way to create an object using templated constructor without parameters with concrete type of template paramter of constructor?
Hello there, subject of a message contains quite completed question but there is an example: I have a class with such templated constructor: class A{ template<typename T> A(const T &t){ //copy data from t } } if I want to create an instance of object A from 'empty' object B I'll write A a(B()); this code contains one "unnecessary" creation of temporary object B and copying from it into A to optimize it I've added another templated constructor into A: class A{ template<typename T> A(){ ...

PALMSOURCE to go the Linux way
Mobile Africa - Accra,Ghana PalmSource, the company behind the popular Palm platform on many handheld devices has announced its intention to migrate from the Palm platform, to Linux. ... <http://www.mobileafrica.net/news-africa.php?id=485> -- http://www.euronet.nl/users/frankvw/rants/microsoft/IhateMS.html ...

Best way to create dynamic update statement
In general, What is the best approach in creating a dynamic update stored procedure, that can handle recieving varying input paramters and update the approporiate columns. Depends on the requirements but one possibility is to use NULL parameters to represent values that shouldn't be changed: UPDATE YourTable SET col1 = COALESCE(@col1, col1), col2 = COALESCE(@col2, col2), col3 = COALESCE(@col3, col3) ... etc WHERE ... -- David Portas SQL Server MVP -- >> In general, What is the best approach in creating a dynamic update stored procedure, << In general, building d...

cheap way to develop a USB device?
What is the cheapest way to develop a USB device? The Cygnal F32x seems good for its on chip USB controller. But it needs the Keil tools which is expensive. Is there any USB tools(hardware/software) exsisted which is under $500 for 8 bit microcontroller like 8051,PIC, or AVR? For very low volume, I need low price development tools. hi look up FT232BM On 15 Dec 2003 10:55:36 -0800, yong wrote: > What is the cheapest way to develop a USB device? The Cygnal F32x > seems good for its on chip USB controller. But it needs the Keil tools > which is expensive. Is there any USB tools(hardwa...

Looking for a better way
Hi I am new to TCL of course, and I have come up with the following piece of code on my own. I would like to know what the experts would do to make this better. I have 3 buttons on a GUI that start, stop and restart my server. I have a procedure defined for each button, it seems a bit overkill and I am sure there is an easier way. Perhaps group the start/stop/restart all together .I will list one of the 3 procs here since they are almost identical. set server "/etc/rc.d/init.d/vsftpd" proc_start {} { global server set start [list exec $server start] eval $start & #Call...

Best way to export to BMDP
Hello again I use SAS (obviously). My boss uses BMDP .... she's been using it a long time and has a lot of programs written in it and so on, and is not interested in giving it up. What is the best way to export data from SAS to BMDP? I have DBMScopy, which does it, but was wondering if there is a way to do it from within SAS ... the EXPORT wizard doesn't seem to have BMDP as an option TIA as always Peter Peter L. Flom, PhD Statistical Consultant www DOT peterflom DOT com I appears that BMDP can read and write SAS/Transport files. But SAS does not create BMDP system files. I w...

Re: Is there a way to find out last(first.) and last(last.) in #2
Proc summary can do this. Assuming I understand what you mean by first last and last first or what ever you said. data new1; input id her subs; cards; 101 1 3 101 1 4 102 2 4 102 2 4.1 102 2 4.2 102 2 5 ; run; proc summary nway data=new1; output out=temp idgroup(max(id her) out(_all_)=) idgroup(max(id her) last out(_all_)=) / autoname ; run; proc print; run; /* or if you don't like the autonames */ /* use 2 output statements */ proc summary nway data=new1; output out=temp1 idgroup(max(id her) out(_all_)=); output out=temp2 idgroup(max(...

Is there a way to
Beable to print from my laptop running win 98 to my desktop running XP through a router? Thanks in advance On Sat, 26 Feb 2005 20:05:29 -0600, Guess Who <me@home.com> wrote: >Beable to print from my laptop running win 98 to my desktop running XP >through a router? >Thanks in advance Yes The router is a simple switch on the LAN side so ignore it. http://www.practicallynetworked.com/sharing/xp_filesharing/index.htm http://www.practicallynetworked.com/sharing/xp/filesharing.htm http://www.practicallynetworked.com/sharing/troubleshoot/ http://www.microsoft.com/te...

5 Powerful Ways to Earn a Degree with Scholarship
Hi! I hope you got my Super Powerful TIP-1 to Earn a Degree without paying for Tution. If not, click here: http://www.ShowRoute.com/FinancialAid and create afree profile. Amazing, isn't it?! Ok, now! Here's the Second TIP: Use the Power of Net. In general, there many websites which act as Directories which list the colleges. You must have experienced that these lists lead you nowhere and you waste hours together searching for degrees with no/less tution or scholarship. To make your job easier, I would recommend to consider a website: 1. That would let you create a profile and l...

Making it through education the hard way
Narcisa Polonio's life story reads like your typical against-the-odds Hollywood drama.But look beyond its big-screen potential and you will find a tale brimming with all the inspiration you need to make it through a time of economic gloom. For more details www.technicaledu.blogspot.com ...