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
set terminal png nocrop font small size 40000,800
set output 'decode3.png'
set style data linespoints
set title "Raw Audio Chunk"
set xlabel "Count"
set ylabel "Sample Value"
set xtics 16 offset 10
set ytics 10000
set grid
plot "decode3_Samsung_Exhibit.csv"

Thats the wrong way of thinking about this! The offset parameter only shifts the xtics labels (in your case by 10 character widths), but the xtics remain at their original positions. And the grid lines are drawn at the tic positions.
What you probably want is to shift the data a bit to the right. That is done by shifting the actual x-values to the right like
set xtics 16
set grid
plot "decode3_Samsung_Exhibit.csv" using ($1 + 10):2
That assumes, that your data file has two columns. The x-values are shifted by 10 (in units of the x-axis) to the right.

Related

increase pixel size in gnuplot

As I said I have 2D matrix 68 per 68 and I want to make a heat map from it.
Each value in the matrix should be displayed as a separate cell. Every fourth cell should be labelled as "XXX\n715" 0, "XXX\n718" 3 and so on...
This is my plot: https://www.dropbox.com/s/tiipsn5mhmbnb5b/TEST.png?dl=0
Data used to produce this plot can be found here: https://www.dropbox.com/s/izrfbm157q1tedj/matrix.dat?dl=0
At present, I can see two problems with my plot:
1.) Cells are too small. Therefore, the plot is hard to read.
I want to increase size of a cell 2 times.
If I understand correctly, each pixel corresponds to one value?
If so, I would like to increase size of a pixel. That's way I was thinking
about drawing a grid size of 68*2/68*2, so that each value in my matrix will
be displayed in a 2-pixel/2-pixel-square box (cell).
2.) Values are outside cells's borders.
I had the same problem with smaller 2D arrays and I fixed it by trying
different resolutions (terminal size). I have been trying to apply a discussed
solution for the 68x68 matrix, but it did not work for me.
I tested many different scripts and I am stuck on these problems.
Thank you.
Code below:
set terminal png transparent truecolor nocrop enhanced size 800,800 font
"arial bold,8”
set output 'TEST.png'
set size ratio 1
set palette rgbformulae -21,-22,-23
# drawing grid
set x2tics 1 format '' scale 0,0.001
set y2tics 1 format '' scale 0,0.001
set mx2tics 2
set my2tics 2
# labels
set xtics 3 out nomirror
set ytics 3 out nomirror
set grid front mx2tics my2tics lw 0.5 lt 1 lc rgb 'black'
set xrange[-0.5:67.5]
set yrange[-0.5:67.5]
set x2range[-0.5:67.5]
set y2range[-0.5:67.5]
set xtics add ("XXX\n715" 0, "XXX\n718" 3)
set ytics add ("XXX\n715" 0, "XXX\n718" 3)
plot "matrix.dat" matrix w image noti

configure gnuplot to handle timeseries like excel

I am trying to graph events over time with gnuplot. Excel's default behavior produces a more readable graph.
I would like my graph from gnuplot to look like Excel's.
set terminal png size 1200,800
set xdata time
set timefmt "%Y-%m-%d_%H-%M"
set output "graph.png"
set xrange ["2015-02-01_08-54":"2015-02-01_23-20"]
set yrange [0:70]
set grid
set xlabel "24-Hour"
set ylabel "Events"
set title "Events"
plot "events.dat" using 1:2 index 0 title "events" with filledcurves ls 1
I've spent many hours manipulating source data and plot.conf, but it's not clear to me what Excel is doing differently.
Gnuplot Output:
Excel Output:
Excel plots with a wrong x-scale: it ignores the time values, and puts the values given in the first column at equidistant x-values as labels.
To get the same behavior with gnuplot, you must use xticlabel to place the values in the first column as tic labels, and use the row number (column 0) as x-values:
set xtics rotate by 90 right noenhanced
plot "events.dat" using 0:2:xticlabel(1) title "events" with filledcurves
Now, this would give you rather unreadable labels, because that are too many. With some tweaks you get a nicer result:
set terminal pngcairo size 1200,800
set output "graph.png"
set yrange [0:70]
set grid y
set xlabel "24-Hour"
set ylabel "Events"
set xtics out nomirror scale 0.5 rotate by 90 right font ',8' noenhanced
plot "events.dat" using 0:2:xticlabel(int($0) % 5 == 0 ? strcol(1) : '') title "events" with filledcurves
Disclaimer: Please use this script only to understand what Excel does and not to reproduce it, because it gives a very wrong impression of the actual time spans in which your events happen!

Plotting data vertically with gnuplot

I have a data file with a single column of data. By default, gnuplot renders this on the x-axis from left to right. However, I want to plot this data vertically from top to bottom. How can I do this?
The relevant excerpt from my plot file:
set size 1.0, 1.0
set terminal postscript eps enhanced color dashed lw 1 "Helvetica" 14
set output "ocean-diffuse.eps"
set autoscale
set xtic auto
set ytic auto
plot '0000086400.dat' using 1 with line, \
'0000172800.dat' using 1 with line
In order to have the single column used as x-value, use:
plot '0000086400.dat' using 1:0
That uses the row number (column 0) as y-values. Of course you can do any scaling and computation with the row number as
f(x) = x
plot '0000086400.dat' using 1:(f($0))
To have the y-axis reversed, use
set yrange [*:*] reverse

gnuplot Title and Axis labels are cut of by half

Ive changed the font size of the Graph title and the x and y axis label to the double size. Now the title and axis labels are much bigger but they are cut of by half and reach into the graph itself.
Is there an option to set a margin for the title so they are plotted complete and without reaching into the graph?
// Im using gnuplot 4.6 patchlevel 0
The label position and the margins are calculated based on the overall terminal font size, which can be set with set terminal or set termoption font ',20'.
So if you increase the font size locally (only for the title and axes labels), the margins and the label positions are wrong.
You can set explicit margins like set lmargin 5, which reserves a left margin corresponding to 5 character widths, or even absolute margins with e.g. set lmargin at screen 0.1. For title and xlabel there is an offset option, which allows to adjust the label position relative to the default position.
set terminal pngcairo size 600,400 font ',10'
set output 'output.png'
set xlabel 'xlabel' font ',30' offset 0,-1
set bmargin 5
plot sin(x)

rotating and justifying tics in gnuplot

I want to rotate the xtics by 45 degree. In another word the direction is /. Problem is the tics will appear inside the chart area, I want to put them outside of chart. See the figure:
You must adjust both the alignment (can be right, center or left) and the offset (x,y coordinates with respect to the default tics position) of the xtics.
Here is an example, which demonstrates the three different possiblities. The offset must be adjusted manually, in order to get it right:
set xrange [0.5:3.5]
set bmargin 5
set multiplot layout 1,3
set xtics ('first' 1, 'second' 2, 'third' 3) rotate by 45 right
set title 'right aligned'
plot x
set xtics center offset 0,-1
set title 'centered'
replot
set xtics left offset 0,-2
set title 'left aligned'
replot
unset multiplot
This gives (with 4.6.4):

Resources