Alexander
Alexander

Reputation: 743

gnuplot x-axis values format

I am trying to create a plot using gnuplot with bytes on the x axis with range [4:4194304]. However it is not very convenient to show bytes on X, rather it will look more readable if there will be bytes [1,512), kilobytes [1K,512K), megabytes [1M,512M), etc.

I have not found a clear way to do this in the documentation. Should I generate it in an input data file explicitly?

Best regards, Alex

Upvotes: 2

Views: 9374

Answers (2)

mgilson
mgilson

Reputation: 309831

If you're OK with using base 10 for the numbers on the label (e.g. 1k = 1000, not 1k = 1024), this gets a lot easier:

set xtics format '%s%c'
#set logscale x 2
set xrange [1:1000**2]
plot log(x)

Otherwise, there's no good way to do it other than to explicitly set the tics:

set xtics ( "512" 512, "1k" 1024, "1M" 1048576, "1G" 1073741824 )
set logscale x 2
plot log(x)

Upvotes: 6

Thor
Thor

Reputation: 47089

You can do simple scaling with using, e.g.:

plot ... using ($1 / 1024**2):2

Upvotes: 3

Related Questions