Change Y-Variable to Ln Y in Gnuplot: How-To Guide for Linear Graphing

  • Thread starter Thread starter VenaCava
  • Start date Start date
  • Tags Tags
    Gnuplot Ln
Click For Summary
To change the y-variable to ln(y) in Gnuplot without modifying the source data file, use the command "plot 'data.txt' u 1:(log($2))". This command allows you to plot the natural logarithm of the y-values directly, enabling a linear representation of exponential decay over time. The previously attempted "set log y" command only alters the y-axis scale and does not affect the actual y-values, making it unsuitable for this purpose.
VenaCava
Messages
20
Reaction score
0
Is there an easy way to change your y-variable in Gnuplot to ln y without changing the source data file?
I already tried "set log y" but that only changed the y-axis scale, not the actual y-values.
Right now I'm plotting an exponential decay and I wanted to make it a linear graph (lny vs time).

Thanks
 
Physics news on Phys.org
Hi VenaCava,

VenaCava said:
Is there an easy way to change your y-variable in Gnuplot to ln y without changing the source data file?
I already tried "set log y" but that only changed the y-axis scale, not the actual y-values.
Right now I'm plotting an exponential decay and I wanted to make it a linear graph (lny vs time).

Thanks

I'm not sure if this is what you want, but if you are using a data file "data.txt" with x and y columns, you can plot the natural log of the y columns with the command:

Code:
plot 'data.txt' u 1:(log($2))
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
4
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 11 ·
Replies
11
Views
2K
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
Replies
7
Views
2K