FAQ Database Discussion Community

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

## Matching a Color Gradient to Data in Gnuplot

I have data showing a change over time, and I have used Gnuplot 4.6 to generate the following plot: Here, I have manually defined eleven line styles to change the color gradually from red (#ff0000) to dark red (#5f0000) as time' progresses. Here was my input: # svg set terminal...

## Gnuplot two x-axis from different files

gnuplot,axis
I want to plot data in a plot with two different x-axes. One should be Time in years the other one time in MJD. This is an example from file 1 (x in years): 2011.27466 0.012 2011.71704 0.019 2011.71716 0.021 2011.87012 0.045 This is an example from file 2 (x...

## How to plot histograms from rows in data file gnuplot

gnuplot,histogram
t.dat file looks like this: 260.37 260.04 261.53 261.32 260.19 260.49 260.43 260.59 260.26 260.68 260.28 259.93 260.82 259.50 260.29 260.52 260.30 259.91 262.24 260.58 260.74 260.22 261.66 260.31 260.99 259.79 260.90 259.88 260.19 261.50 259.32 260.79 259.94 260.35 260.03 260.07 261.86 261.09 260.60 260.15 75.17 75.16 75.33 75.31 75.34...

## Lua Error: “Gnuplot terminal is not set”

lua,gnuplot
In LuaJIT or in the Torch REPL, I run the commands require 'gnuplot' gnuplot.figure() and I get the error "Gnuplot terminal is not set". I tried using gnuplot.setterm() with some guesses such as 'x11' and 'qt' as arguments, but get the error "gnuplot does not seem to have this term"....

## gnuplot command line arguments and call arguments

gnuplot,command-line-interface,interactive

## GNUPLOT: Joining different series of points with vectors

function,vector,gnuplot,points
I have a file with data in 2 columns X and Y. There are some blocks and they are separated by a blank line. I want to join the points (given by their coordenates x and y in the file) in each block using vectors. I'm trying to use these...

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

## Extend x-axis beyond xrange in gnuplot

gnuplot,axis
I am trying to draw a larger x-axis than my xrange. I.e. my xrange is [0:10] I plot f(x)=sin(x) But I want the x-scale to be from 0 to 15 xtics doesn't solve this problem as it will not extent beyond the set xrange. jlinkels...

## Lost Data Point in Gnuplot

gnuplot
I have a simple time series: 2015-05-03 07:00,58 2015-05-03 08:00,61 2015-05-03 09:00,65 2015-05-03 10:00,69 2015-05-03 11:00,72 2015-05-03 12:00,74 2015-05-03 13:00,76 2015-05-03 14:00,78 2015-05-03 15:00,78 2015-05-03 16:00,78 2015-05-03 17:00,77 2015-05-03 18:00,76 2015-05-03 19:00,73 2015-05-03 20:00,70 2015-05-03 21:00,67 2015-05-03 22:00,66 2015-05-03 23:00,64 2015-05-04 00:00,63 2015-05-04 01:00,62 2015-05-04 02:00,62 2015-05-04 03:00,61 2015-05-04 04:00,61...

## 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: Fitting asymptotic curve to data

gnuplot
I am trying to fit an asymptotic curve to my data using gnuplot. It is a dataset showing reaction time results over a testing period. I have been able to plot the data and fit a straight line through it using the following code. f(x) = a*x + c; fit...

## specific gnuplot by data grouping

data,gnuplot,std,mean
I'm new in gnuplot and sorry that my problem formulation might be unprecise, but I don't know how to find the tools/commnds needed to solve my problem. The code for plotting I would like to integrate in my bash file. I have a data set like: 285 1 50 7.35092...

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

## Gnuplot - Graphic appears and disappears when zooming

graphics,gnuplot
I'm trying to plot some graphics in gnuplot, and I find out that canvas doesn't show the whole curve. It shows different graphics for different zooms. What could I do to solve this?...

## Surface plot piping to gnuplot from C

c,2d,gnuplot,surface,piping
I've made a function which successfully pipes data from my C program to gnuplot: void gnuprintabs(FILE *gp,double **RE,double **IM, double x[], int N) { int i,j; fprintf(gp, "splot '-'\n"); for (i=0; i<N; i++) { for(j=0; j<N; j++) { fprintf(gp, "%g %g %g\n", x[i],x[j],sqrt(RE[i][j]*RE[i][j]+IM[i][j]*IM[i][j])); } } fflush(gp); fprintf(gp, "e\n"); } The...

## gnuplot: strange pattern on color palette

gnuplot
I am using a color palette like this: set palette defined (0 '#0000ff', 1 '#ff0000') I expect the color palette on the plot to be a smooth transition from blue to red but what I get is this: As you can see there are like more transparent steps in between....

## 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 how to add more space to indexes in labels

plot,gnuplot
I try to put the space to the index in the letters of the labels of Gnuplot. I use the following command: set terminal pngcairo size 500,400 enhanced font 'Verdana,10' set output 'test.png' set xlabel 'atan(~{/Symbol w}{.6\~}_2)' set ylabel 'atan(~{/Symbol w}{.6\~}_2)' plot sin(x) As you can see from the plot...

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

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

## Symbols in Gnuplot label

plot,gnuplot
Code in terminal qt and gnuplot 5.0 plot x; set xlabel 'Magnetic field {/Symbol Mu}_0' which works in gnuplot prompt. However, {/Symbol mu}_0 is not working in Commandline script /usr/local/bin/gnuplot -e "plot x; set xlabel 'Magnetic field {/Symbol m}_0 H / mT'`; I get gdImageStringFT: No character set found while...

## Changing title within loop

gnuplot
I am using gnuplot 5.0, and I have a data set I would like to plot using key1 = 'Some title with multiple words' key2 = 'Some other descriptive title ' key3 = '...and a third title' plot for[i=1:3] datafile index i-1 using 1:2 with lines title eval('key'.i) This is...

## How to get labels on top of bars in gnuplot

gnuplot
I want a barchart with labels on top of the bars, showing a group of bars, with errors, and labels on top of the bars indicating how much this bar differs from the first one. Although i get the positioning about right, it is always a little off. Y seems...

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

## 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: Multiplot size and scaling of one plot

gnuplot,histogram
I have this multiplot: Generated by the following code: set terminal pdf size 15,10 set output "graph.pdf" set key off set multiplot layout 5, 1 scale 1, 1 set style data histograms set style histogram set style fill solid border -1 set boxwidth 0.75 set yrange [0:178] set ytics 50...

## How to get my Mac OS X terminal to control gunplot properly?

gnuplot
I am using gunplot on mac os x (Yosemite). I can plot data, but I can't do a lot of customization: commands like: set tics "", or rotate by ... don't work. Do you think it's a problem from the installation or terminal? Thanks!...

## Is it possible to read the value of a label in gnuplot from a file

gnuplot
Creating labels in gnulot is quite simple set label "<value>" at <x,y> ... But I want to read the value of a label in gnuplot from a file. The lines in the file look this way: ... 400 300 8 0.200214 1.00193 7.42157 8.623714 86.06 13.94 1.26 800 600 1...

## Plot all files in a directory simultanously with gnuplot?

gnuplot
I want to do something similar to this question: gnuplot : plotting data from multiple input files in a single graph. I want to plot simultaneously all the files in a directory, without having to explicitly write their names. The column numbers are the same for all the files. What...

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

## Distinct bars of different group in Gnuplot for printing

plot,gnuplot,histogram
The problem for me is how plot (using gnuplot) bars with different styles in a figure so that they can be print. Take data from http://www.ibm.com/developerworks/aix/library/au-gnuplot/ for example, the data is: #Disk.txt hdisk2 420 425 410 hdisk3 700 780 760 hdisk4 450 450 452 hdisk5 680 702 690 hdisk6 320...

## Set arbitrary base of logarithm in gnuplot

gnuplot
I would like to ask how can I set arbitrary base of logarithm in gnuplot (I would need f(x)=x^{1+9log2(x)} function to plot).

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

## gnuplot: scale axis of matrix plot

gnuplot
I have a matrix, output.dat: 0 0 0 0 0 0 3 7 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 16 6 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

## Two Boxplots for one X position using gnuplot

graph,gnuplot,boxplot
I have 2 sets of data A and B, each with a y value for x=100, 200, 300. I want to create one graph which shows the difference between these two data sets. As such this means that for each x, there will be two boxplots(one for data A and...

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

## Can I have multiple colors in a gnuplot label?

label,gnuplot
I have this graph in gnuplot: I want to include totals for each of the three colored line graphs. One possibility is to replace the key with this: Can I plot this with a single label that switches colors? If not then I'd have to use six labels. In that...

## Unable to plot bargraph using gnuplot

gnuplot
I'm seeing an issue while plotting the bar graph using gnuplot. Im using gnuplot version 4.6 on Windows 7. I'm seeing an error message ";" expected. Here is the logic: # bar graph #set title "Programming language" set xlabel "Programming" set ylabel "Execution time" set auto x set yrange [0:120]...

## gnuplot: plotting points with color based iris data

gnuplot,classification,svm,libsvm
I have this iris data ... 5.1 3.5 1.4 0.2 Iris-setosa 4.9 3 1.4 0.2 Iris-setosa 7 3.2 4.7 1.4 Iris-versicolor 6.4 3.2 4.5 1.5 Iris-versicolor 7.1 3 5.9 2.1 Iris-virginica 6.3 2.9 5.6 1.8 Iris-virginica . . . and I got graph using gnuplot (plot 'c:\iris.data') but I want...

## gnuplot, multidimensional array, plotting, matrix,

arrays,matrix,multidimensional-array,plot,gnuplot
I am new to GNUPLOT and, I have encountered a problem which I do not know how to deal with. Any help from your side will be appreciated. The problem is: I have two files, say "A.dat" and "B. dat". Both are multidimensional array data. To be exact, A.dat has...

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

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

## Application of Gnuplot figure as transparent on top of image

plot,gnuplot
I would like plot on the top of png figure as transparent and no axes in Gnuplot. If legend can be fitted there, it would be great. Its code which is based on many discussions of mine in gnuplot here set xrange [2014:2050]; set yrange [40:125]; set datafile separator "...

gnuplot,javaplot

## How to Set Precision in GNU Plot Graph Range?

gnuplot
I set the range in my plot like such set yrange[ 0.000 : 0.040 ] and the graph's interval is 0.005 on the y-axis. The y-axis reads like 0.04 0.035 0.03 0.025 0.02 0.015 0.01 0.005 0 on the side of the graph. This looks totally inconsistent. How can I...

## Counting number of plotted points in gnuplot

gnuplot
The data file contains values in the following format: 0 0 50 0 1 70 1 0 40 1 1 70 2 0 110 2 1 60 3 0 60 3 1 120 4 0 50 4 1 50 5 0 70 5 1 70 This is a code snippet...

## Gnuplot command with multiple “with” arguments

command-line,plot,gnuplot
Plotting in Gnuplot: For example if one tries to both set the datapoint type and the errorbars into one command, there's a conflict of "with" arguments, i.e.: plot "test.csv" using 1:2:3 with points pointtype 5 with yerrorbars The error message is as follows: duplicated or contradicting arguments in plot options....

## How do I skip rows in Gnuplot when plotting a heat map?

gnuplot,heatmap
I'm trying to plot a heat map in Gnuplot: set view map set size square set cbrange [0:1] splot "input.dat" 1:4:8 w pm3d But I want to skip the rows with the data in the first & fourth column in a particular range without changing xrange and yrange. How can...

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

## To plot stacked histogram in Gnuplot from this data

plot,gnuplot
Data Year Water Power Wood Power 2025 58.1 41.9 2035 55.8 44.2 2050 50.6 49.4 Code set style histogram columnstacked; set terminal qt size 560,270; set grid; set offset 1,1,0,0; plot 'RES.dat' u 1:3; which gives where it somehow omits the first sentence of the command. I tried to set...

## How to output smooth cspline curve as a data file

output,gnuplot,smooth
Does anybody know how to extract some data of smooth cspline curve for a given data? For instance, there is a data file which has 2 columns corresponding to x and y values. I can draw the data with smooth cpline curve by the following commands p 'data' w lp,...

## 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?

## gnuplot wxt not working anymore

gnuplot
I have recently upgraded to Debian jessie, meaning that I have upgraded from gnuplot 4.6.0 to gnuplot 4.6.6 (issue is the same with gnuplot 5.0). I have bash scripts automating things, and launching gnuplot terminal. I was using either: gnuplot -persist -e "set title 'Sine curve'; plot sin(x)" or gnuplot...

## Animating a single data file using gnuplot

animation,gnuplot
I use FORTRAN 77 code to generate data (saved as filename.dat) of simple physics situations containing x-y co-ordinates like a projectile. My data files usually have 2 or 3 columns like so: 1 1 2 2 3 3 4 4 5 5 I can plot (2d and 3d) using Gnuplot...

## Gnuplot graph with circles, color and radius dependent on input

gnuplot
I have to make graph with gnuplot from some kind of input data. There is date, score and count for every entry. Graph should be with x axis representing date (I'll probably have question for that in the future too :/ ), y axis score and count should be represented...

## Gnuplot different colors inside newhistogram

gnuplot,histogram
I am plotting a histogram rowstacked very similar to this graph (the last one on this page) : What I would like to do is to have different colors for each year bin. This colors would repeat from a newhistogram to another. I have not yet found a way to...

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

## Passing variable to gnuplot via -e causes not persistent window

bash,shell,gnuplot
I want to run either persistent gnuplot or write output to file. This behavior should be affected by passing variable. Here is my test.plg: #!/usr/bin/gnuplot -p if (exists("file")) set term png; set output "test.png"; if (!exists("name")) exit; set title name plot sin(x) If I run script this way it is...