Upper axis values through linking with lower axis gnu plot

  • Thread starter CAF123
  • Start date

CAF123

Gold Member
2,888
87
I am trying to link the upper axis with the lower axis in gnu plot, that is print out values on the upper axis given a relationship between the upper axis, x2, quantities and the lower axis, x, ones. The relationship between them is

Code:
x2 = 2*c**2/(2*x**2-c**2)
with
Code:
c=3.1
The following should be sufficient

Code:
    set xlabel "Quantity lower"
    set xtics nomirror
    set x2label "Quantity Upper"
    set x2tics nomirror
    set link x2 via 2*(3.1)**2/(2*x**2-(3.1)**2) inverse sqrt((3.1)**2*(2+x)/2/x)

    #set link x via 1239.8/x inverse 1239.8/x

    set ylabel "Quantity y"
    set ytics 0.2
    set samples 400
    Spectrum(x) = exp(-(x-500)**2/(400))

    set xrange[30:2000]

    set format x2 "%.2f"
    plot Spectrum(x) w l title "Spectrum"
I've also log formatted the x axis via

Code:
set logscale x
set format x "10^{%L}"
but regardless of whether I include the log formatting I am unable to get any meanginful values printed out on the upper axis. (The function for y is for illustrative purposes only, the value for y in my actual script relies on reading in data from a file)

I'd like to print out values on the upper axis for two values of x=100, 1000 say. Not sure if this is the right place for this but thanks for any comments!
 

CAF123

Gold Member
2,888
87
@Mark44 Hi, looks similar but not quite the same - there they are plotting two different relationships (x2 v.s y2) and (x1 v.s y1). All I want to do, and I hoped it would have been trivial to do, is to link the x2 axis (upper axis) with the x axis (lower axis). That is, for a given tick mark on the x axis with value ##X##, I want to print out the corresponding tick mark on the x2 axis with value ##x2(X)##, where
Code:
x2 = 2*c**2/(2*x**2-c**2)
as given in my OP. Does my question make sense?
 

DrClaude

Mentor
6,870
3,014
That is, for a given tick mark on the x axis with value ##X##, I want to print out the corresponding tick mark on the x2 axis with value ##x2(X)##
This is not what set link x2 will do. The second x axis gets its own set of tics, so it will not mirror the position of the tics on the first x axis. To see this, try
Code:
set tics nomirror
set xrange[1:10]
set link x2 via 1/x inverse 1/x
set x2tics
plot x
 
32,571
4,301
@CAF123, what's happening with your other thread, the one about evaluating a function at numerous points? Your last (and only) post in that thread was almost five days ago.
 

CAF123

Gold Member
2,888
87
This is not what set link x2 will do. The second x axis gets its own set of tics, so it will not mirror the position of the tics on the first x axis. To see this, try
Code:
set tics nomirror
set xrange[1:10]
set link x2 via 1/x inverse 1/x
set x2tics
plot x
I see. Can you suggest a way for me to proceed with what I want to do?
 

CAF123

Gold Member
2,888
87
@CAF123, what's happening with your other thread, the one about evaluating a function at numerous points? Your last (and only) post in that thread was almost five days ago.
I managed to come up with a solution outside of C++, i may come back to the thread later to discuss more.
 

Want to reply to this thread?

"Upper axis values through linking with lower axis gnu plot" You must log in or register to reply here.

Related Threads for: Upper axis values through linking with lower axis gnu plot

  • Posted
Replies
0
Views
130
D
  • Posted
Replies
7
Views
28K
  • Posted
Replies
4
Views
2K
Replies
12
Views
506

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top