Path: csiph.com!1.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Karl Ratzsch Newsgroups: comp.graphics.apps.gnuplot Subject: Re: Plot 2D, from a file that contains blocked data every time x changes. Date: Sun, 12 Mar 2017 11:28:26 +0100 Organization: solani.org Lines: 40 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: solani.org 1489314504 19060 eJwNysEBwCAIA8CVAiUg4yCW/UfQ9x0/F+8wpxuH064LxWrw5MTOFByXmT0/EEV9a6k+S6DsAh3QENM= (12 Mar 2017 10:28:24 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sun, 12 Mar 2017 10:28:24 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 X-NNTP-Posting-Host: eJwNy8ERwDAIA7CVWowhjEOps/8IyektIt6Y9GA496XgQxOAypVwVJuLQ1ktrF9h6m+0q2/qA/9LELg= In-Reply-To: Cancel-Lock: sha1:yZFnlZfK9uH1EYL7nTmsALU9iQg= X-User-ID: eJwFwYEBwCAIA7CXZNCi5wyw/59gAqexMwgGBO1P23uuIbyNQ0veSqmQEaBWrGrlHP531nkbWhFC Xref: csiph.com comp.graphics.apps.gnuplot:3573 Am 11.03.2017 um 21:32 schrieb David Carrasco de Busturia: > I have a data.dat file that looks like: > > # z y x > 25.04 12.50 10.00 > 24.01 11.30 10.00 > 25.03 12.50 10.00 > 22.01 14.20 10.00 > > 27.05 14.28 20.00 > 28.01 12.30 20.00 > 27.70 13.37 20.00 > 27.10 14.08 20.00 > Now, in the same gnuplot script, I would need to plot 2D graphs in which: > > I plot the variation of z as a function of y for different values of x. One graph with plot lines for x=10,20,etc. ? plot for [i=1:10] dataf ev :::i::i using 2:1 w l you can find out the number of data blocks in dataf with the "stats" command. It is in the variable "STATS_blocks" afterwards. (Run "show var STATS" to see all available statistics.) Getting the value of x into the legend is a bit tricky. You cannot use the stringcol() function in the "title" specifier, and it gets (afaik) evaluated before any data is plotted, anyway. So you need to read in the dataset twice, storing the relevant information: titlestr = '' plot i=0, dataf us (n=column(-1), (n == i)?(titlestr=titlestr.stringcolumn(3).' ', i=i+1):0,$2):1 plot for [i=0:2] dataf ev :::i::i using 2:1 w l title word(titlestr,i+1)