Upper axis values through linking with lower axis gnu plot

  • Thread starter Thread starter CAF123
  • Start date Start date
  • Tags Tags
    Axis Plot
Click For Summary

Discussion Overview

The discussion revolves around linking the upper axis (x2) with the lower axis (x) in gnuplot, specifically to display values on the upper axis based on a defined mathematical relationship. The context includes technical aspects of gnuplot configuration and plotting, with an emphasis on axis linking and formatting.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes a relationship between the upper and lower axes defined by the equation x2 = 2*c**2/(2*x**2-c**2) with c=3.1, and expresses difficulty in getting meaningful values printed on the upper axis.
  • Another participant suggests a reference to a gnuplot demo that may illustrate a similar concept of multi-axis plotting.
  • A participant clarifies that the goal is to link the x2 axis to the x-axis such that for a given tick mark on the x-axis, the corresponding tick mark on the x2 axis should reflect the calculated value x2(X).
  • One participant points out that using set link x2 will not achieve the desired mirroring of tick marks, as the second x-axis has its own set of tics.
  • A participant requests suggestions for how to proceed with their original goal after realizing the limitations of the current approach.

Areas of Agreement / Disagreement

Participants express differing views on the functionality of gnuplot's axis linking features, with some agreeing on the limitations of the set link x2 command while others seek alternative solutions. The discussion remains unresolved regarding the best method to achieve the desired axis linking.

Contextual Notes

Participants note that the second x-axis does not mirror the first due to its independent tic settings, which may affect how values are displayed. There are also references to other threads and potential solutions that have not been fully explored.

CAF123
Gold Member
Messages
2,918
Reaction score
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!
 
Technology news on Phys.org
@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?
 
CAF123 said:
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
 
@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.
 
DrClaude said:
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?
 
Mark44 said:
@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.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
1
Views
6K
  • · Replies 6 ·
Replies
6
Views
4K
Replies
2
Views
15K
  • · Replies 3 ·
Replies
3
Views
2K