conditional,gnuplot , Gnuplot: Conditional splot of a function

Question:

Tag: conditional,gnuplot

I want to splot the function exp(-(x²+y²)) alone and under the constraint of x+y-1=0. The result should be the surface alone as well as a line with a maximum at x=y=0.5. Or in other words, it's the intersection of the function with a (110)-plane.

What I came up so far is something like

``````f(x,y)=exp(-(x**2+y**2))
g(x,y)=( (x+y-1==0)? f(x,y) : (1/0) )
splot f(x,y), g(x,y)
``````

with and without with lines for g(x,y), but I could not get g(x,y) being displayed - I only see f(x,y). Additionally, I get the very informative error messages:

``````Error: Key "<META>" added to modifier map for multiple modifiers; Using Mod4, ignoring Mod1

Error: Symbol "Meta_L" added to modifier map for multiple modifiers; Using Mod4, ignoring Mod1
``````

Any ideas?

This is not a 3-dimensional plot because you only have one independent variable. The value of `y` is fixed by `x+y-1=0`. Therefore, you have to plot `f(x,y)=exp(-(x**2+y**2))` evaluated at `f(x,1-x)`:

``````f(x,y)=exp(-(x**2+y**2))
plot f(x,1-x) w l
``````

Now, of course the above graph is the projection of your curve onto the XZ plane. If you want the 3-dimensional view, then I would recommend a numerical evaluation of the function using the special file name `"+"`:

``````f(x,y)=exp(-(x**2+y**2))
set xrange [-10:10]
set yrange [-10:10]
splot "++" u (\$1):(1.-\$1):(f(\$1,1.-\$1)) w l
``````

You can visualize the intersection with your surface:

``````set isosamples 50
splot f(x,y), "++" u (\$1):(1.-\$1):(f(\$1,1.-\$1)) w l
``````

Related:

Using Razor Syntax within JavaScript Conditional Statment

javascript,c#,asp.net-mvc,razor,conditional
In an index.cshtml I have the following working code similar to: <script type="text/javascript"> if ([email protected]' === 'True'){ Do Something(); } </script> The === 'True' seems like an odd hack to me to force Razor and JavaScript to get along. How can I refactor to use === true? This doesn't give...

How to set font-weight of a column text to bold based on another column value in Telerik Grid

telerik,formatting,conditional,client-templates
I have a Telerik grid in which based on whether my IsTrue value is true or false, I need to set the font-weight of Name text in only that particular row to bold. I tried the following but I seem to be missing something. columns.Bound(d => d.IsTrue).Width(0).HtmlAttributes(new { id="hdnIsTrue", style...

Plotting multiple columns with a for loop in gnuplot, key doesn't work

for-loop,gnuplot
I have file with many columns that I'd like to plot as follows: plot for [i=1:30] 'test' using 1:i w lp This gives the plot I want, but when I do set key, then the key I see has all lines labeled as 1:i: How can I make this output...

gnuplot rowstacked histogram: how to put sum above bars

label,gnuplot,histogram
This question is related to gnuplot histogram: How to put values on top of bars. I have a datafile file.dat: x y1 y2 1 2 3 2 3 4 3 4 5 and the gnuplot: set style data histogram; set style histogram rowstacked; plot newhistogram 'foo', 'file.dat' u 2:xtic(1) t...

Conditional group by join in R

r,join,conditional
I am new to R and rather flumoxed by the following problem. I have two vectors of dates (the vectors are not necessarily aligned, nor of the same length). I want to find for each date in the first vector the next date in the second vector. vecA <- as.Date(c('1951-07-01',...

Creating a hexplot

r,matlab,matplotlib,gnuplot,matlab-figure
I am trying to create a figure like the one depicted in the third column of the following image: Link for the image in case of backup. Basically I have x and y positions of 200 particles and I have the MSD data for these 200 positions. I'd like MSD...

How to plot columns numbered greater than 1000 in gnuplot

plot,gnuplot
I have a file with 1600 columns. plot "file" using 1:999 title columnhead(999) plots column 999, but plot "file" using 1:1000 title columnhead(1000) produces column 100 instead of 1000, producing the same result as plot "file" using 1:100 title columnhead(100) Apparently large column numbers are wrapped. Is there a work-around...

Does anyone know how to get rid of the “small bar” in a gnuplot graph?

gnuplot
Below is my gnuplot code. set term pdf enhanced set output "plot/test.pdf" set datafile separator "," set xtics norangelimit set ytics nomirror set termoption dashed set xlabel "times" set yrange [0:100] set xtics nomirror set grid ytics set key right bottom plot 'plot/test.csv' using 2:xtic((int(\$0)%20)==0?sprintf("%d", \$0*10):"") title "Comparing with the...

Offset gnuplot grid lines so that they match xtics

gnuplot
How do I move the vertical grid lines so that they match the horizontal labels/xtics? In the following image, the vertical grid lines don't line up with the xtics: I tried setting the xtics offset before setting the grid, but that doesn't seem to work.Here's my current script: #!/usr/bin/gnuplot -persist...

gnuplot - splot inline data and point labels

gnuplot,labels
Hi Im using this data to get a 3d/2d like histogram. I want to label each histogram column with a 'dx cx' label preferable on top of the column. With my example the graph is drawing correctly, but there are no labels. if I'm using only the using 1:2:3:4 with...

gnuplot highlighting points when with lines

plot,gnuplot,highlight
I have 4 points I would like to plot using gnuplot, but with lines. The problem is, I can't find how to highlight these 4 points on the drawn line. I would like for the plot to be a line through the points, but that these points are also clearly...

gnuplot - get errors on fit parameters, get fit output values as variables, print variable to screen

variables,gnuplot,curve-fitting,data-fitting,function-fitting
Initial Question (Partially Answered) I am using gnuplot's fitting routines to fit a function to some data, and extract a "characteristic decay time constant". (I call this parameter d in my fitting function.) I have used the script code set fit quiet to prevent reams of text being printed to...

Show text for post with specific date and specific category in Wordpress

php,wordpress,date,conditional
So I'm trying to show text at the end of each post but from this month only and only in one category. I tried different codes that I found here but none of them really worked or what I needed. Here is example of what I like to do. Hope...

Elastic Search : General and conditional filters

elasticsearch,conditional,apply,exists
I'm using Elastic Search, with query match_all and filtering. In my situation I want to apply a general filter and filters by condition. Here in pseudo: query: match all (works fine) filter range date between d1 and d2 (works fine without bullet 3) filter (apply only if field exists, but...

Create a Triangular Matrix from a Vector performing sequential operations

r,for-loop,matrix,vector,conditional
I have been trying to solve the following problem. Suppose I have the following vector: aux1<-c(0,0,0,4,5,0,7,0,0,10,11,12) where the numbers represent the number of the row. I want to calculate the distance between the differents elements of this vector fixing the first component, then the second and so on. If the...

How to write a conditional on two variables (columns) in Pandas

python,pandas,conditional
I'm trying to count instances when there was no login, but there was a card-view, and create a new column with the count (or True). I used the conditional statement below and got a key error. Can someone help me figure out what's going on? import pandas as pd import...

Plotting the inverse of the numbers in columns in gnuplot with for loop

for-loop,gnuplot
I want to plot the inverse of the numbers in a number of columns against the first column: plot for [i=1:30] 'file' using 1:(1/i) w lp which results in all the y values to be zero. It works when I remove the for loop and just pick a column to...

Gnuplot plotting all datafiles automatically

bash,gnuplot
I have multiple *.data files each has same format and can be plotted with this simple script: cat << __EOF | gnuplot -persist set terminal pdf set output 'out.pdf' set datafile separator ";" set boxwidth 0.5 set style fill solid plot "xxx.dat" using 1:3:xtic(2) with boxes __EOF How can i...

gnuplot - How can I count the number of entries in a csv file column?

csv,plot,gnuplot,function-fitting
I have a gnuplot code which includes a function fitting routine. This routine is slow when a large number of data points must be fitted. The number of data points in my input file is variable depending on the parameters of some simulations I am running. I wish to fit...

Set label on group multiplot in gnuplot

linux,graph,plot,gnuplot
Im plotting one picture with 4 different graphs using gnuplot. Labels for their x and y axes have the same meaning. If Im plotting it like this: set multiplot layout 2,2 rowsfirst set xlabel "x" set ylabel "y" set title offset -3,-3 set xrange [20:70] set yrange [0:15000] set title...

How to make gnuplot to NOT plot multiple lines?

plot,scripting,gnuplot
I am plotting some data and I am getting multiple lines streaking across the plot. There should be one line, so I imagine that gnuplot is trying to fit the data and is joining points or something in a strange way. How can I get gnuplot to plot one like...

Set with lines in gnuplot

gnuplot
I can connect the dots of a data file by including with lines in the plot command. Is there a way to set this fixed (I was hoping for set with lines) so I don't have to explicitly include it in every call of plot?

Can I set a default Y range in gnuplot?

gnuplot
My graphs will be generated based on runtime data, such as user-provided time ranges. I can't know ahead of time whether data within the requested xrange will actually exist. In the case that it's not, I'd like to show a blank plot (with X=time range as requested, but arbitrary Y...

C++ Gnuplot pipe input from C++ defined variables

c++,pipe,gnuplot
I am using C++ to pipe commands to gnuplot using the following code: FILE *gnuplotPipe = popen("gnuplot -persist", "w"); // Open a pipe to gnuplot if (gnuplotPipe) { // If gnuplot is found fprintf(gnuplotPipe, "reset\n"); //gnuplot commands fprintf(gnuplotPipe, "n='500'\n"); fprintf(gnuplotPipe, "max='1500'\n"); fprintf(gnuplotPipe, "min='-1500\n"); fprintf(gnuplotPipe, "width=(max-min)/n\n"); fprintf(gnuplotPipe, "hist(x,width)=width*floor(x/width)+width/2.0\n"); fprintf(gnuplotPipe, "set term...

Deleting rows in R conditionally

r,conditional,delete-row
I have a data where the first column is a bunch of ID numbers (some repeat), and the second column is just a bunch of numbers. I need a way to keep each ID number only once based on the smallest number in the second column. Row# ID Number 1...

Conditional Logic for links in ACF

php,wordpress,if-statement,conditional,acf
So here is what im trying to do. Im using Advanced Custom Fields for this and am outputting a title with a link, But sometimes their is NO link. When there is NO link I don't want this to be wrapped in a tag but I can't seem to figure...

Rails 4 validation conditional on value of a hidden field

ruby-on-rails,validation,conditional,hidden-field
How can I perform a validation only if the value of a hidden_field matches a specified value? For example, I have two forms each with a separate submit button and a separate hidden_field, the value of which determines whether to run one set of validations or another. The problem seems...

Gnuplot: Conditional splot of a function

conditional,gnuplot
I want to splot the function exp(-(x²+y²)) alone and under the constraint of x+y-1=0. The result should be the surface alone as well as a line with a maximum at x=y=0.5. Or in other words, it's the intersection of the function with a (110)-plane. What I came up so far...

Gnuplot, normalize over x axis

gnuplot
I've got two datasets referring to the same process executed in two different ways. The execution A is slower than the execution B with respect to real time, but the two graphs represent the same phenomena.. I can plot the two together as follows: plot 'A' using 1:2, 'B' using...

How to draw a histogram with broken x-axis and string labels?

gnuplot,histogram
I am trying to draw a histogram with broken x-axis. I learnt the basic solution from this post. However, the x-axis of my histogram is based on strings, not number. It's like this: set terminal pdf set output "test-bar.pdf" set boxwidth 1.0 absolute set style fill solid 1 border 0...

Is it possible to “print” gnuplot's output directly to STDOUT?

c++,gnuplot
I am using a third-parter utility named gnuplot-iostream to invoke gnuplot from C++ in the back-end of a web application. That web application is executed under CGI, so anything that goes to STDOUT is the result to browser. In this case, the web request will be for the image itself,...

How to select subplot in gnuplot multiplot mode

gnuplot,subplot
is there any way to select a subplot in gnuplot's multiplot mode as in subplot(n,m,x) in Matlab where x is the one I want to plot at? I am plotting three points using linespoints on a graph in red color at first, then I want to plot a single point...

.NET use IIF to assign value to different variables

.net,vb.net,conditional,variable-assignment,iif
Could I (and if so how) do the following in .NET language (more specifically VB.NET): Dim a,b as Integer if(somecondition=1,a,b) = 12345 Or any variant with IIF would be fine by me. Basically I'm always assign the same value but never to the same variable.....

Conditional subtraction Part 2

r,conditional,multiplication
I have a big data.frame (TOTAL) with some values (cols11-16) that I need to subtract a base from which is multiplied by a value depending on two conditions in TOTAL. The data.frame (TOTAL) looks a little like this Channel Hour Category cols11 cols12 cols13 cols14 cols15 base TV1 01:00:00 New...

C++ Pass a string into a pipe to gnuplot

c++,string,pipe,gnuplot
I'm having a small problem passing a string to gnuplot from c++ I can pass integers easily enough, but when I try a string (user defined as "title" earlier in the code): fprintf(gnuplotPipe, "set title %s\n", title); I get the error: error: cannot pass objects of non-trivially-copyable type ‘std::string {aka...

Boo Language Calculation on Web Drop Down List

if-statement,conditional,boo
The software we use LanDesk Service Desk uses Boo Language calculations to allow for dynamic windows. I have a drop down list on a form that has one of two options. "Acute" and "Ambulatory". Based on which is chosen, one of two possible fields will no longer be hidden and...

One liner conditional, multiple variables and check that all of them are not false?

python,if-statement,conditional,conditional-statements
How I can make a conditional in python that checks for this three keywords defined in the dictionary and that they are not False ? settings = { 'proxy_host': '127.0.0.1', 'proxy_port': 8080, 'proxy_protocol': 'socks', } I have tried with the sentence you can see below. But this is only checking...

Gnuplot bar chart from this CSV input

bash,gnuplot
I have csv file data.dat for example with these values: #W=1 0;sqlite;11500 1;hsql;14550 2;h2;17550 #W=2 0;sqlite;11000 1;hsql;13800 2;h2;16500 #W=3 0;sqlite;11000 1;hsql;13800 2;h2;16500 #W=4 0;sqlite;11000 1;hsql;13800 2;h2;16500 I need to plot bar charts into pdf. each data for each graph starts with title #W1,#W2.... i have tried this script: cat <<...

Keep the second occurrence in a column in R

r,conditional,subset,find-occurrences
I have quite a simple dataset: ID Value Time 1 censored 1 1 censored 2 1 uncensored 3 1 uncensored 4 1 censored 5 1 censored 6 2 censored 1 2 uncensored 2 2 uncensored 3 2 uncensored 4 2 censored 5 I want to keep the first uncensored occurrence,...

plotting points in 3d surface using x,y,z coordinates

3d,gnuplot
I need to plot some points in 3d surface based on x,y,z coordiantes values in a file named as test.dat test.dat file contains At-No X Y Z 6 3.532210 -2.171743 0.921140 7 1.164869 -1.418981 0.782133 1 2.454732 2.332989 -0.907213 6 -3.246376 -1.047325 -0.602590 6 -2.620684 0.053348 -0.013310 6 -4.569969 -1.249720...

Python AND OR statements

python,if-statement,conditional
I am parsing text with Python and I have this final code to write sentences, but it does not work well: opt = child.get('desc') extent = child.get('extent') if opt == 'es': opt = "ESP:" elif opt == "la": opt = "LAT:" elif opt == "en": opt = "ENG:" if opt...

Can I plot times when they're given as UNIX timestamps with added milliseconds?

datetime,gnuplot
I'm using gnuplot 4.4 on CentOS 6.6. I've found many examples online showing that the following (note the use of %.3S) will enable timestamps like "12:42:51.047" to be parsed and used as X axis values: set xdata time set format x "%H:%M:%.3S" set timefmt "%H:%M:%S" However, my input is not...

How to highlight regions of plot with gnuplot

I'd appreciate if somebody can help with this question. I am working with a radar (or spiderweb) plot with gnuplot 5.0.0: The scale and range in all axes is the same. The numbers at and beyond 1 have a special meaning and I would like to highlight that. I am...

MySQL Conditional Left Join With Default

mysql,left-join,conditional
Is there a way to make a conditional left join, which will left join on a default value if a match is not found? I have a client table and a preference table. Record 0 in the preference table is my global default preference. There are cases in which a...

Chance of a conditional occurring in Swift: Xcode

xcode,swift,if-statement,conditional,percentage
I am quite new to Xcode and swift so sorry if this is a bad description. Is there a way that there is a chance of your conditional occurring so instead of it happening 100% of the time when the conditions are met, it only happens 50% of the time...