conditional,gnuplot , Gnuplot: Conditional splot of a function

Gnuplot: Conditional splot of a function


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

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):

plot f(x,1-x) w l

enter image description here

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 "+":

set xrange [-10:10]
set yrange [-10:10]
splot "++" u ($1):(1.-$1):(f($1,1.-$1)) w l

enter image description here

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

enter image description here


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...

Set label on group multiplot in 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...

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

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...

Can I set a default Y range in 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...

Conditional Logic for links in 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...

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

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...

Gnuplot bar chart from this CSV input

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 <<...

MySQL Conditional Left Join With Default

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...

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

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': '', 'proxy_port': 8080, 'proxy_protocol': 'socks', } I have tried with the sentence you can see below. But this is only checking...

Conditional group by join in R

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',...

How to select subplot in gnuplot multiplot mode

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...

Using Razor Syntax within JavaScript Conditional Statment

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...

Create a Triangular Matrix from a Vector performing sequential operations

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...

gnuplot highlighting points when with lines

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, normalize over x axis

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...

Set with lines in 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?

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

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

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...

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

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 plot columns numbered greater than 1000 in 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...

Boo Language Calculation on Web Drop Down List

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...

How to make gnuplot to NOT plot multiple lines?

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...

Rails 4 validation conditional on value of a 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 - splot inline data and point 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...

Python AND OR statements

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...

Gnuplot plotting all datafiles automatically

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 rowstacked histogram: how to put sum above bars

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...

.NET use IIF to assign value to different variables

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.....

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

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...

Conditional text for certain categories within taxonomy.php

I am building a Wordpress site using 'Easy Digital Downloads'. The downloads have their own 'categories'. To display an archive of those categories (different from the standard archive.php) I am using a template called taxonomy-download_category.php as specified in their documentation. This works perfectly and I can set up the category...

Keep the second occurrence in a column in R

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,...

Elastic Search : General and conditional filters

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...

Creating a hexplot

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...

about drawing sinus function in gnuplot when it is pressed a keyboard

Is it possible to draw sinus function on the interval: [-2*pi, 2*pi] in the following way: when I press right arrow on the keyboard to produce sinus function on the interval: [-2*pi, -pi] when I press again to plot sinus function on the interval [-pi, 0] .... Is it possible?...

Storing reference (hash?) to the node for conditional manipulation

Given this pseudo-code: <xsl:variable name="check0"> <xsl:value-of select="($externalFile//i[@attibute = $variable]/..[email protected] < $genDate) and ($externalFile//i[@attibute = $variable]/..[email protected] > $genDate)"/> </xsl:variable> <xsl:variable name="check1"> <xsl:value-of select="($externalFile//i[@attibute = $variable]/..[email protected] < $genDate) and ($externalFile//i[@attibute = $variable]/..[email protected] > $genDate)"/> </xsl:variable> Above code checks if some variable is in date range of attributes taken from...

Deleting rows in R conditionally

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...

C++ Pass a string into a pipe to 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...

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

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...

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

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...

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

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...

Gnuplot: Conditional splot of a function

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...

Conditional subtraction Part 2

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...

Chance of a conditional occurring in Swift: Xcode

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...

Offset gnuplot grid lines so that they match xtics

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...

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

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 - How can I count the number of entries in a csv file column?

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...

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

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...

How to set a conditional based on multiple models?

notifications/index has <%= render partial: "notifications/notification", collection: @notifications %>, which contains: <% if Comment.find_by(notification.comment_id) == @habit %> <%= link_to "your habit", habit_path(notification) %> <% else %> <%= link_to "your value", valuation_path(notification) %> <% end %> which shows gives the error for the 1st line: Couldn't find Habit with 'id'= even...

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

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...