问题
I set the y-axis in power notation (1.0e+5 or 1.0 * 1.0^5) but I would like to report the power just on top of the axis to save space. In particular I would like to report at the end of the axis as reported in the link
回答1:
I guess is very common to put the prefactor in the label (instead of top of the axis). If you absolutely need it on top, let me know. One way would be the following. There would also be ways to determine the prefactor automatically.
Code:
### prefactor for axis
reset session
Power = 5
set format y "%.2f"
set ylabel sprintf("Ω [10^%d rpm]", Power) enhanced
f(x) = 3e4*sin(x)+1.2e5
plot f(x)/10**Power w l notitle
### end of code
Result:
回答2:
Try use this commented code:
# Creating some 'x y' data to plot and
# save output using 'table' and
# datablock named 'data'
set table $data
plot (1E-5 + sin(x)*1E-5)
unset table
# Performs statistics using 'y' column
# to find max value, turn off output, and
# set prefix name 'data' to stats results
stats $data u 2 nooutput name 'data'
set tmargin at screen 0.94 # Change the top margin
# Define a label containing the power to base 10
# of max value from data and put on top-left
# using the same value of top margin
# but using offset on y axis
set label gprintf('×10^{%T}',data_max) at graph 0.0, screen 0.94 offset 0,0.75
set format y '%.2t' # Format for 'y' values using mantissa
# to base 10 and 2 decimal places
set xlabel 't' # label to 'x' axis
set ylabel 'Ω' # label to 'y' axis
unset key # Turn off key (legend)
set tics nomirror # Turn off upper and right tic marks
# The plot itself
plot $data using 1:2 w l
Produces
来源:https://stackoverflow.com/questions/56795402/gnuplot-power-notation-axis