Hello Daniweb,

As my title, I have a problem in my gnuplot.

I can set the minimum range based on my file.. but doing the maximum range it give a wrong output for min and max yrange.

I been searching for net and tried there solutions but it won't work for me.

This is my script line for me yrange:

set yrange [*:35] noreverse nowriteback
#set yrange [*:*] noreverse nowriteback

The first line is working, but to get the best graphical image is getting the min max of the data.

The second line is not working, as I see that is the closest answer on my problem.

Please help me to get the min max for my yrange.

This is my script:

#!/usr/bin/gnuplot
reset
set terminal pngcairo
set datafile separator ','
set style fill solid 0.3
set grid
set title 'Test Guide'
set offset graph 0.05, graph 0.05, graph 0.05, graph 0.05
set yrange [*:35] noreverse nowriteback
#set yrange [*:*] noreverse nowriteback
set ylabel 'Temperature'
set xlabel 'Day 0 to Day 5'
set output 'test.png'
plot 'new_test.dat' using 2:xticlabels(1) with line t 'Testing'

Thank you and God Bless

Dani AI

Generated

Short, practical summary and fixes (builds on and )

Autoscaling in gnuplot computes axis limits from the data actually plotted. The symptom described here — wild or “wrong” yrange when trying to autoscale both limits — almost always comes from non‑numeric values in the column used for the y data (headers, stray text, empty fields, quoted values, etc.). That matches what found after removing columns with text; was right that autoscale can behave oddly, but the root cause is usually mixed-type data rather than an infinity bug.

A reliable way to get exact min/max and then force the yrange is to use gnuplot’s stats command to compute numeric limits from the y column and then apply them:

stats 'new_test.dat' using 2 name 'S' nooutput
# S_min and S_max now hold numeric min/max; S_invalid counts non-numeric rows
set yrange [S_min:S_max]

If S_invalid > 0 then the data file contains entries gnuplot could not parse as numbers. Inspect the CSV for a header line, empty fields, non‑numeric tokens like "NA" or "test", thousands separators or stray quotes. Common fixes: remove or skip the header (use skip 1, every ::1, or set key autotitle columnhead), set a missing-value token (set datafile missing "NA"), or pre-clean the CSV so the plotted column contains only numbers.

Other quick options: leave yrange unset (or use set autoscale y) so gnuplot decides automatically, or explicitly set min or max if a fixed bound is desired. In practice the stats approach above is robust for scripts: it explicitly detects invalid rows (S_invalid) and provides precise S_min/S_max to use for plotting.

Recommended Answers

All 2 Replies

I think that the failing yrange set [:] is failing because you are trying to set the yrange to infinity which gnuplot cannot handle. I'm not a gnuplot expert, so this is just a SWAG.

Hello Sir Rubberman,

I just delete some of the data to my extracted file. Adjusting to my file is the only way I can do. After I delete first and second column the [:] is now working. The problem I think is even the string/text is included to the graph I make. But thank you for the time and reply sir.

PS: Sorry for late feedback

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.