Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #1392

Re: Way to limit xtics in histogram

Newsgroups comp.graphics.apps.gnuplot
Date 2012-09-26 01:28 -0700
References <ed92043c-f58f-4541-9111-0881e39c3c7e@l30g2000yqb.googlegroups.com> <hj7oo2$lo2$1@news.eternal-september.org> <dbf37f28-f5fe-4214-bbac-898896ef1ecd@f12g2000yqn.googlegroups.com> <d5e1e715-56f7-4ad1-927a-9e4eda243ed0@u15g2000prd.googlegroups.com>
Message-ID <cba1883d-f9d9-425c-92f8-828e04f1281a@googlegroups.com> (permalink)
Subject Re: Way to limit xtics in histogram
From diru91@googlemail.com

Show all headers | View raw


Am Montag, 8. März 2010 08:05:59 UTC+1 schrieb 噜噜老公:
> On Jan 21, 9:42 am, 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.  The basic idea should be evident
> > > from this command:
> >
> > >   everyfifth(col) = (int(column(col) % 5 == 0) ? "A" : ""
> > >   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) = (int(column(col))%10 ==0)?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.

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) =((int(column(countColumn)) % N == 0) ? stringcolumn(labelColumnNum) : "");

and you have to use it this way:

plot ... u 1:xtic(everyNth($2,2,10))

Back to comp.graphics.apps.gnuplot | Previous | Next | Find similar


Thread

Re: Way to limit xtics in histogram diru91@googlemail.com - 2012-09-26 01:28 -0700

csiph-web