hertzsprung
hertzsprung

Reputation: 9893

How to rescale x axis when plotting a function in gnuplot

I've already seen How to scale the axis in Gnuplot, but I'm not sure how this would work with a function such as

set xrange[-10:10]
f(x) = x**2
plot f(x)

My actual function isn't so easily rescaled as the one above. All I want to do is change the units on the x axis from metres (which is what f(x) accepts), to kilometres.

Upvotes: 0

Views: 1699

Answers (1)

Christoph
Christoph

Reputation: 48390

If your function definition f(x) needs metre and you want your x-axis to display kilometres, then you must scale x by 1000:

set xlabel 'kilometres'
set xrange [-0.01:0.01]
f(x) = x**2
plot f(1000*x)

Upvotes: 3

Related Questions