Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Ethan Merritt Newsgroups: comp.graphics.apps.gnuplot Subject: Re: Histograms, re-use auto yrange Date: Wed, 23 Jan 2019 04:59:26 -0000 (UTC) Organization: A noiseless patient Spider Lines: 36 Message-ID: References: <1fddbd1c-ec65-4120-8167-fa9fe5885311@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 23 Jan 2019 04:59:26 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="e78ddc286c282d4dc989e885e66ec34b"; logging-data="19221"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/v/7eGBwGLMXkQBiJrl+2I" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:37d6Vmf5+0XQqvlM57++wQJf1b0= Xref: csiph.com comp.graphics.apps.gnuplot:4122 On Tue, 22 Jan 2019 08:36:23 -0800, Stephen Prather wrote: > Hi forum-- > > I am trying to plot multiple histograms, but I want them all to have the same yrange so that the bars are visually comparable across plots. BUT, I also want gnuplot to auto-range the y axis. I don't mind plotting in two passes (plot all, capture max yrange, replot all). But I don't know how to query the value of the yrange into a variable. I know about 'show yrange'. But I don't know how to use that information. I could script around gnuplot (ie, Ruby), but if I'm going to do that, I just as well write my own bucketizer in Ruby to determine the max height of buckets across my datasets. set yrange [*:*] writeback plot 'first-histogram' ... set yrange restore plot 'other-histograms' Here is the relevant help text from the documentation: The `writeback` option essentially saves the range found by `autoscale` in the buffers that would be filled by `set xrange`. This is useful if you wish to plot several functions together but have the range determined by only some of them. The `writeback` operation is performed during the `plot` execution, so it must be specified before that command. To restore, the last saved horizontal range use `set xrange restore`. For example, set xrange [-10:10] set yrange [] writeback plot sin(x) set yrange restore replot x/2 results in a yrange of [-1:1] as found only from the range of sin(x); the [-5:5] range of x/2 is ignored. Executing `show yrange` after each command in the above example should help you understand what is going on. > Since gnuplot is not a general programming language, I think this may be too tall of an order. Sure would be cool if it were a full language (or re-built on top of an existing one). > > Thanks! > --Myles