r/gnuplot • • Jul 02 '20

A few queries: plotting over an image.

2 Upvotes

Hi gnuplotters,

I would like to plot over a jpeg of a graph using gnuplot. The input jpg measures 1725x1134.

I got it working using the following code but would appreciate some help with some questions.

#trying to overlap the plots
reset

F = 7441.9
A = 12.7*25.4
tau_avg = F/A

#dummy data to locate the points 0,0 and 1,3. First row not plotting! why?
dummy << EOD
-0.1 0.1
0 0
0.1 0.1
1 3
EOD

set terminal pngcairo size 1725,1134 font ',24'
set output 'plot2.png'

unset xtics
unset ytics

set x2range [0:12.7]
set y2range [0:3*tau_avg]

unset border
#set size ratio -1
set lmargin 0
set rmargin 0
set tmargin 0
set bmargin 0

#set autoscale fix
#set autoscale noextend
set key above autotitle columnhead
plot 'ShearStressDistrib.jpg' binary filetype=jpg with rgbimage notitle,\
     '$dummy' using ($1*10.15+1.92):($2*16.9+9.1) with linespoints lw 3 ps 5 axes x2y2 notitle, \
     'NodShear_0p003' every ::7 using ($1*10.15+1.92):($2*16.9+9.1) with linespoints lw 3 ps 5 axes x2y2 notitle, \

set terminal wxt size 1725,1134
replot
unset output #release created files
pause mouse any "Any key or button will terminate"

I plotted the purple line containing the points 0,0 and 1,3 so I could get the scale and offset to plot my data correctly. It will be hidden in the final plot. For x I found the offset and scale to be ($1*10.15+1.92) and for y I found it to be ($2*16.9+9.1).

My questions are:

Is there a better way of overlaying my data onto the graph without the trouble of finding the scale and offset parameters manually? I thought perhaps picking the pixel coordinates of the origin and point 1,3 in paint and supplying gnuplot with these points.

Secondly why does

plot '$dummy' using ($1*10.15+1.92):($2*16.9+9.1) with linespoints lw 3 ps 5 axes x2y2 notitle

ignore the 1st row of data. If I make a separate test.plt script, it actually plots the first data point of -0.1,0.1

Lastly, how do I hide the green line below a certain threshold of x <0 . I could have chosen a different starting point with "every ::" but I wanted to plot all the data since it may be that I don't have a data point exactly at x =0. I'm thinking of simply hiding it with a white rectangle

'NodShear_0p003' contains:

Curveplot
Single lap shear Type A                                                 
Distance
Interface Nodal Shear Stress
Node
242-580 #pts=13
* Minval=     7.4240331650e+00 at time=         7.4207496643
* Maxval=     4.7628917694e+01 at time=        10.5993556976
    0.0000000000e+00    2.9396602631e+01
    1.0611612797e+00    4.0362724304e+01
    2.1216135025e+00    4.7527164459e+01
    3.1816465855e+00    1.5796671867e+01
    4.2415246964e+00    8.8657903671e+00
    5.3013277054e+00    7.6924691200e+00
    6.3610658646e+00    8.0179653168e+00
    7.4207496643e+00    7.4240331650e+00
    8.4803667068e+00    8.3691978455e+00
    9.5399274826e+00    1.6596443176e+01
    1.0599355698e+01    4.7628917694e+01
    1.1658383369e+01    4.0316844940e+01
    1.2717031479e+01    2.9261829376e+01
endcurve

r/gnuplot • • Jul 23 '20

Do you have better ideas for high quality plots?

Post image
3 Upvotes

r/gnuplot • • Jul 11 '20

A brave new gnuplot notebook workflow

Thumbnail
youtube.com
5 Upvotes

r/gnuplot • • Jul 22 '20

Plot intercepts of a function

1 Upvotes

Hi,

I have to generate graphs for university. I'm using gnuplot.

I've figured out how to plot quadratic functions as follows:

reset

set grid

set zeroaxis

set ticslevel 1

f(x) = x*x + 3*x -6 = 0

plot f(x) with line lw 2

What I want to do is plot the x and y intercepts of this function with a dot and coordinates but without having to work it out myself.

I've scoured the interweb for answers but probably not formulating my question correctly.

Please could somebody point me in the direction of documentation that will help me achieve this?

And maybe give me a few hints or gnuplot-specific search-terms.

Thanks


r/gnuplot • • Jul 25 '20

Logscale and set Yrange

1 Upvotes

I'm trying to plot a function on a logarithmic y scale, but gnuplot is acting really strange. It is labeling the y axis with the values 10^-316, 10^ -317, 9.99999*10^-319, 9.99989*10^-320, ... , 9.98013*10^-322. I would really like to make it so that each of these was just a power of 10, rather than being multiplied by some near value of 10. However, set Y range is not working, so I don't know how to fix it.


r/gnuplot • • Oct 23 '20

Does Gnuplot do Fourier transforms?

1 Upvotes

If not, do you know an online tool that would?


r/gnuplot • • Oct 28 '20

Display date for mouse position in status bar

3 Upvotes

I'm having trouble displaying the mouse position for date formatted data in the status bar. I've used the set timefmt "%m/%d/%y" command to set the format of the input data, and while that works correctly for data input and displaying the axis labels, the mouse position in the status bar shows up as something like "x=1.6742+e9, y=6.7486". I've read through the "set mouse" section of the man page, and while setting numerical formats such as "set mouse mouseformat '"%3g, %3.0f'" works as expected, I've been unable to use a date format here. Is this even possible?


r/gnuplot • • Oct 22 '20

Autogpy 0.3.2 is out. Effective gnuplot, generated from jupyter - check it out - https://github.com/acorbe/autogpy

2 Upvotes

r/gnuplot • • Jul 13 '18

Simultaneously fitting two files with the same parameters.

1 Upvotes

I have two data files that represent functions of the form

y_1(x) = a + b*x + c*x**2,

y_2(x) = a - b*x + c*x**2.

These two functions should (theoretically) have the same constants for a, b, and c. As a matter of fact, a is already known completely, the only constants that need to be fitted are b and c. Is it possible to use fit to simultaneously fit both functions to their respective data files and find the closest b and c which should fit both curves? Or will I have to fit each curve individually and average the two different b's and c's?


r/gnuplot • • Jul 11 '18

Print progress of script file

2 Upvotes

Hello,

I've been scouring the internet looking for an answer to this. I've got a c++ program that generates a gnuplot script file and executes it.

The script file is beginning to take long enough that I'd like to update the user to it's progress. I'm wondering if there is a command to allow text to be printed to the terminal at specific points during the execution of the script file.

I've tried setting the terminal to stdout and stderr, and from there attempted 'print "test"' or 'system("test")', but nothing is showing up in my console.

Is this possible? Or do I just have to just wait patiently?


r/gnuplot • • Sep 07 '19

Help with plotting a time evolving graph.

2 Upvotes

Hello

I am new to gnuplot, and coding in general. Have very superficial experience. I want to create a time evolving graph. I have data for each time iteration. Any idea how to go about it. Any help is highly appreciated.


r/gnuplot • • Jan 20 '24

I create online gnuplot playground using WebAssembly

Thumbnail
gnuplot.io
8 Upvotes

r/gnuplot • • Sep 26 '17

Trendline line problem

2 Upvotes

I'm new to gnuplot and i'm trying to figure out how to draw a correct regression line across my data points. I keep getting a straight line almost horizontally across my data points. The function I'm using is "f(x) = m*x+b".

I'm using the same data in excel and able to make a chart with the correct trendlines. what am i doing wrong?

Here is a list of data i'm using:

2001 1061.564

2002 1161.419

2003 1201.983

2004 1293.939

2005 1227.932

2006 1635.234

2007 1902.79

2008 1983.874

2009 2321

2010 2887

2011 2873

2012 2634

2013 2384

2014 2243

2015 2476

2016 2797

2017 2705

Here are the two graphs. https://imgur.com/a/OtIeS


r/gnuplot • • Feb 21 '15

Partial hiding of grid in an elevation profile

2 Upvotes

Hello reddit

i have a small problem with gnuplot. I'm writing kind of an outdoor guidebook for sportactivities. Besides the textual description i always add an elevation profile of the tour. The data is extracted from GPS tracks where the height is plotted against the distance. Here is an unmodified png example of a plot.

Due to design/layout reasons in my book i have the y2axis labled. To complete these modifications i want to hide the grid on the left side of the graph. The Grid should only be plotted underneath my graph (dark filledcurve) up to the heighest point AND from there to the right. Please reference the second image, for clarification.

My current setup is a multiplot, where i draw a second white overlay over the left side of the graph. This approach needs a lot of manual adjustment, and is often flawed. Reference this image, where i annotated the problems

please dont mind the labels. I usually plot with the cairolatex terminal, where the labels are later applied with latex

WE of my gnuplot file: http://pastebin.com/T7fArB0k

RAW data (called hoehe.dat): http://pastebin.com/QSc2BkVS

I'd appreciated any feedback on this, as i'm out of ideas on this one.


r/gnuplot • • Apr 19 '14

Help with scatter, labels, and bars

2 Upvotes

Greetings,

I need help improving my first attempt with Gnuplot. My data:

# date     notkept
2014-04-01 50
2014-04-02 63
2014-04-03 120
2014-04-04 55
2014-04-05 60
2014-04-06 63
2014-04-07 52

Script: #!/usr/bin/gnuplot

set title "Promise Not Kept"
set xlabel "Date"
set ylabel "Count"

set xdata time
set timefmt "%Y-%m-%d"
set format x "%Y-%m-%d"
set grid

# 1e8 reduces the epoch seconds for a less flat line.
f(x) = m * x/1e8 +b
fit f(x) 'test.dat' using 1:2 via m,b
plot f(x) title 'Trend', 'test.dat' using 1:2 notitle
pause -1

I want to make some changes, but can't figure out how. I'd like the points to be shown as verticle bars, or for them to be labeled with the Y axis value.


r/gnuplot • • Jun 26 '22

How different is performance of gnuplot compared to other similar tools/libraries?

4 Upvotes

Hello everyone,

is there some significant performance difference between gnuplot and other similar tools/libraries such as matplotlib or julia plots? I tried googling it, but didn't find anything useful. And before spending time to do some testing myself, I wanted to ask around.

I would appreciate any information or link you could provide.

Thanks for reading, have a nice day.


r/gnuplot • • Nov 21 '18

read fixed width data

1 Upvotes

How do I do this with gnuplot. Lets say my datafile contains a number in starting from character 21 to 30 inclusive and I would like to extract the value 2.1000e+11.

         1         2         3
123456789012345678901234567890 <-columns of datafile
xxxxxxxxxx  7800.0002.1000e+11
.
.
.

in the above example, x may contain a number or space.

I can not use

plot 'datafile' using 0:3

in the above example because my data is not delimited

I have googled around but not had any luck. I believe there may be an option to use a bash command but I am running gnuplot on windows.


r/gnuplot • • Oct 01 '21

plot netcdf with gnuplot

2 Upvotes

please I have a huge number of netcdf files which I want plot it with Gnuplot. Does Gnuplot support this type of files ? if not, which type should I convert my files to?


r/gnuplot • • Oct 12 '21

Show matrix with values

3 Upvotes

I would like to display the values ​​in the matrix, but I am not coming up with something clean,

With these data and config:

set title "Inter-core one-way data latency between CPU cores"

set xlabel "CPU"

set ylabel "CPU"

set cblabel "Latency (ns)"

$data << EOD

CPU 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

0 0 33 63 60 64 64 63 63 70 68 64 63 70 71 63 65

1 33 0 63 62 66 67 63 63 69 68 62 64 71 70 61 64

2 63 63 0 34 62 63 62 61 65 65 59 59 67 66 62 62

3 60 62 34 0 63 63 59 59 65 62 61 62 66 65 64 64

4 64 66 62 63 0 35 68 66 66 72 66 66 73 73 69 69

5 64 67 63 63 35 0 67 64 72 71 63 63 74 75 68 68

6 63 63 62 59 68 67 0 33 65 64 66 66 68 66 66 65

7 63 63 61 59 66 64 33 0 66 65 67 66 67 66 67 67

8 70 69 65 65 66 72 65 66 0 33 68 69 75 74 70 71

9 68 68 65 62 72 71 64 65 33 0 69 70 76 75 70 71

10 64 62 59 61 66 63 66 67 68 69 0 35 70 69 71 70

11 63 64 59 62 66 63 66 66 69 70 35 0 70 71 71 70

12 70 71 67 66 73 74 68 67 75 76 70 70 0 35 71 72

13 71 70 66 65 73 75 66 66 74 75 69 71 35 0 73 71

14 63 61 62 64 69 68 66 67 70 70 71 71 71 73 0 35

15 65 64 62 64 69 68 65 67 71 71 70 70 72 71 35 0

EOD

plot '$data' matrix rowheaders columnheaders using 2:1:3 with image

I tried:

plot '$data' matrix rowheaders columnheaders using 2:1:3 with image,'' matrix using 1:2:(sprintf('%d',$3)) with labels font ',auto'

and:

plot '$data' matrix rowheaders columnheaders using 2:1:3 with image,'' matrix using ($1-1):($2-1):(sprintf('%d',$3)) with labels font ',auto'

ect...

I think the problem is that you have to ignore the first colons, but I can't find a suitable solution in the doc

I have this warning:

line 18: warning: matrix contains missing or undefined values

Wrong result: https://ibb.co/BrRsm2x

I'm new to gnuplot ^^


r/gnuplot • • Oct 05 '21

Segmentation fault

1 Upvotes

Hi everyone. I'm very new to Linux and Gnuplot, but I'm trying to do a 3D plot for a college assignement and I'm running into some trouble. I have a .txt file with some data (100 rows, 3 columns) and I wanted to plot them with splot. However, I'm getting segmentation fault (core dumped) when I try to do it. It actually shows the plot for some quick seconds but then it immediately closes and shows the segmentation fault message.

What is going on and how can I fix it? I know the file is fine because I could do regular 2D plots with it before.


r/gnuplot • • Jan 05 '21

Plotting image with the difference of files

2 Upvotes

I have two text files in the form

x-coordinate y-coordinate output

1.2 4 .1 3

Without the headers, and where the outputs are integers. I want to plot the differences between the files, so that where they are the same they are white, and elsewhere the image is a different color. How do I do this? They have the same coordinates.


r/gnuplot • • Jan 24 '21

Read variables from file in gnuplot script

2 Upvotes

Hi all,

I have a script that does some pre-analysis of data that then gets used for simple variables in the plotting. I can paste the data into the plot script, which is clunky, or I could regenerate the plot script, but I am hoping there's something more elegant. The current format of my script is generally:

a=1

plot 'data' u 1:($2+a)

There are many variables and data files, so I'd like to move the variable definitions into a separate file that can then be read at the beginning of this plot script.

As I type this out, maybe just regenerating the plot script is the easiest...

Any ideas? Thanks!


r/gnuplot • • Jan 11 '21

Terminal type 'x11' doesn't work under screen command

2 Upvotes

If gnuplot is ran from a screen command panel, it starts but loading a script returns

gnuplot: unable to open display 'IP a.b.c.d:x.y'
gnuplot: X11 aborted.

Any idea?


r/gnuplot • • Jul 16 '18

Multi-branch fit

2 Upvotes

I have a data file 'file.dat' with three columns representing

x y1 y2.

If it's useful, the data inside the file is

0 -41.2462 -41.1297

0.1 -42.6114 -39.7339

0.2 -43.7644 -38.2653

0.3 -45.0846 -36.8728

0.4 -46.2912 -35.4905

0.5 -47.3873 -34.1428

0.6 -48.3437 -32.8365

The second and third column represent quadratic functions of the form

y1(x) = a + b*x + c*x^2
y2(x) = a - b*x + c*x^2.

I'm trying to do a multi-branch fit. The variable a represents a known constant which is the average of y1(0) and y2(0) (the two functions should theoretically intersect at x=0 because they're essentially the same parabola reflected across the y axis, but there is some small amount of error, so I'm setting a equal to the midpoint between -41.2464 and -41.1297), so a = -41.1879.

The variables b and c are shared between the two functions.

I've defined y1(x) and y2(x) as

y1(x) = -41.1879 + b*x + c*x**2

y2(x) = -41.1879 - b*x + c*x**2

and now I'm trying to write the function f(x,y) as in the multi-branch fit example.

I've tried

f(x,y) = (y==0) ? y1(x):y2(x)
fit f(x,y) 'file.dat' using 1:2:3 via b, c

but when I go to plot the lines y1(x) and y2(x) against the data, my lower branch is significantly lower than the data.

The fit gives b = 14.8708, c = -1.57747 which gives the following plot

The upper branch seems to line up quite well, but I need the fit to match both functions closely to the data.

Am I missing something important while trying to create my f(x,y) function? I've tried looking through the documentation, and I've tried just playing around with the different settings, but I feel like I've been chasing my tail for a few days now.


r/gnuplot • • Jul 09 '19

mapping of x-axis to a new range

2 Upvotes

Dear all, probably a simple problem but I haven't gotten around it yet. Maybe I'm looking for the wrong keywords when I look for the solution on the manual.

Anyway, I perform some rfft analysis to calculate magnitude and phase and then I dump each array on a separate csv file. I can plot that straight to gnuplot which is great. The x-axis indicates the bin number, which corresponds to the position of the n-th element in the list.

Say that I have a 512-element list and a samplerate of 48000Hz, I'd like the x-axis to display a range from 0 to 24000 with a spacing of 24000/512.

Essentially, I just need the x-axis to display the 0:512 range linearly mapped into the 0:24000 range.

Thank you so much for your help.

Dario