gnuplot


Composite xrange in gnuplot


I have a periodic system and I want to fit some data for this system to a function, but I want to constrain to a range. Usually, if your range is from x_min to x_max this can be achieved with fit [x_min:x_max] f(x) "data" via a,b,c,.... However, because my system is periodic, I want to constrain to a range that contains a segment at the end of the array of x values and also at the beginning. That is, if x values are given within the interval [0:L], I want to include in the fit both [0:x_max] and [x_min:L], where in this case x_max < x_min. How can this be done?
How about this?
fit [min1:max2] f(x) "data" u 1:($1 <= max1 || $1 >= min2 ? $2 : 1/0) via a,b,c,...
That is, make use of the [:] for the outer range.
I'm not sure it's much nicer but it is a little bit shorter.
Alternatively, you could use set table in the following way:
set table 'newdata'
p [0:x_max] 'data'
p [x_min:L] 'data'
unset table
fit f(x) 'newdata' via a,b,c,...
Basically this writes a new file containing only the data between the two ranges. Arguably nicer, definitely not shorter!
I figured an ugly way to do it, but if anyone comes up with a nicer way I will accept that as the answer.
Imagine the two ranges where you want to fit (or plot) the data are given by [min1:max1] and [min2:max2], then using a conditional fit and the "ignore" function 1/0 you can do the following:
fit f(x) "data" u 1:( ($1 >= min1 && $1 <= max1) || ($1 >= min2 && $1 <= max2) ? $2 : 1/0) via a,b,c,...
That is, if x is within the first interval or the second one, then use y as a value for the fit, otherwise ignore those data points.
This approach should also work with plot, but I think something like a composite range operator [min1:max1 && min2:max2] (which does not work) would be more desirable.

Related Links

how to plot data which has mostly true values in gnuplot?
GNUplot concatenate 2 macros in an xlabel
Determine min and max in gnuplot
Plot cyclic sum of some row data
How to count the number of indices in a Gnuplot input file
GNU Plot how to plot histogram in timeseries
Create groups of dots histogram with gnuplot
Gnuplot: Missing values on second y-axis
Gnuplot fat lines overlap with axis
Using relative paths in gnuplot plot files
increment of ytics in gnuplot
gnuplot: Plot and fit 2d function with two variables
Gnuplot: Plotting a path over a surface
How to mark 90 percentile in gnuplot
Is there a way to have gnuplot use xaxis time data, but skip certain intervals (e.g. non-trading hours)
How can I make gnuplot show coordinates of a plotted function which have same x value as the mouse pointer?

Categories

HOME
c++
github
sitecore8
multidimensional-array
jsoup
composer-php
masonry
wildfly
web-crawler
g2o
bootstrap-datepicker
reactor-netty
ais
google-cloud-endpoints
android-animation
xhtml
apache-spark-2.0
gemfire
javacard
chapel
datepicker
benchmarking
conv-neural-network
cognos-10
jxmaps
pentaho-spoon
twincat-ads
accurev
zillow
workspace
apl
fxml
neoscms
radio
layer
state
product-key
dexguard
direct3d9
angularjs-ng-model
war
r6
scalacheck
google-console-developer
itunes-store
behavior
django-compressor
jsdoc3
c++1z
fuzzy
sift
erlang-shell
vqmod
jake
outlook-2016
nslog
cscore
ms-project-server-2013
z-order
htsql
countdowntimer
markov-models
client-side
idfa
gethostbyname
wns
into-outfile
customdialog
rgraph
httpful
jlist
template-strings
spatialite
joptimizer
zend-http-client
mysql-error-1093
stacked-area-chart
nxt-python
sandbox-solution
bitmapimage
rails-i18n
parallel.for
commission-junction
inference
citrix-access-gateway
eclipse-wtp
emacs-dirtree
nservicebus3
static-array
fatwire
dvorak
mbprogresshud
python-sockets
sqa
set-include-path
trx
xml-comments
language-theory
executequery
mkstorekit
comdlg32
remote-administration

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App