I am trying to plot a column greater than 10, but I get an error when I use {}.. like in regular bash. How do I tell gnuplot to do this?
plot '../data.txt' using (${11}:$2)
Give these two possibilities a try:
plot '../data.txt' using 11:2
plot '../data.txt' using ($11):($2)
Related
I have some measured data, experiment.dat which goes like this:
1 2
2 3
Now I want to plot them via some command line
plot "experiment.dat" using 1:2 title "experiment" with lines lw 3
Is there some way how to scale the different lines with some scaling factor like -1?
Yes, you can do any kind of calculations inside the using statement. To scale the y-value (the second column) with -1, use
plot "experiment.dat" using 1:(-1*$2)
You don't need to multiply the column by minus one, you can simply use:
p "experiment.dat" u 1:(-$2)
at least with Version 5.4 works fine.
You can also only use the initial letter of every command.
What are the possible ways to plot (isosurface!) a datafile with four columns (x,y,z,f(x,y,z))? Is it possible using gnuplot?
No, this is not possible with gnuplot, but you might want to use octave, which uses gnuplot as backend (still). There, see the isosurface function.
I could not describe how the plot looks like so I just use "strange" as I have no idea why gnuplot gives me such a plot. Here is the thing I am trying to do.
I have a data file with two columns, the first column is the file name and the second is the size of each file. Each column is more than 2 million rows. I just want to plot the distribution of file sizes. Here is my code
set terminal postscript landscape enhanced mono dashed lw 2 "Times" 18
outputfile = "sizedist.ps"
set output outputfile
binwidth = 0.05
bin(x,width)=width*floor(x/width)
plot [0:3.5][]'sizedist.out' using (bin(log10($2/1024),binwidth)):(1.0) smooth freq with boxes t "Binsize=0.05 dex"
set terminal x11
Ideally, it should be a single Gaussian-like bar plot, but it has many other plots over-layed (see my attachment). Any expert on gnuplot knows why this happened?
This happens if some of your data in the frequency plot does not have well defined values (such as NaN, inf etc.).
Since you are using a logarithmic function in the plot, you have to be careful with data that has values <=0. I guess you have files with size=0. In this cases log10 just gives you NaN and this messes up the counting procedure of the frequency plot.
Include a condition to your plot to fix this. For example:
plot [0:3.5][]'sizedist.out' using ($2>0?bin(log10($2/1024),binwidth):0):(1.0) smooth freq with boxes t "Binsize=0.05 dex"
I am trying to use gnuplot to plot results from my experiments.
I wrote a C++ program that generates a datafile that looks like this:
10 3.5
11 3.5
12 3.5
13 3.6
What I am trying to do is to display the values of the first column of this datafile on the x-axis as powers of 2. It would look something like that (It doesn't have to look exactly the same):
http://i.stack.imgur.com/8BSLr.png
So with the datafile I posted, I want to have 2^10, 2^11, etc on the x axis.
Any idea how to do that?
I can change the format of the datafile if needed.
Thanks!
this is done relatively easy by manipulating the using specification:
plot datafile using (2**$1):2
If you do this, you'll probably also want a
set logscale x 2
set format x '2^{%L}' #<- enhanced text.
to make the plot look nicer.
I am using gnuplot (Version 4.4 patchlevel 2) to generate rowstacked histograms, very similar to the example called "Stacked histograms by percent" from the gnuplot demo site at http://www.gnuplot.info/demo/histograms.html
I want to display the values of each stacked box within it.
I.e. I want to display the actual numerical value (in percent and/or the absolute number) of each box.
How can I do that?
How many numbers do you want to enter.
If it is just a few then have you tried
set label "label" at 2,3
If there are many then you can write a script to decide where to put the numbers - something like here
Plotting arrows with gnuplot
Don't know a way to do it by magic, although I am not very familiar with rowstacked histograms
Tom