Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

plot - Gnuplot: multiplot and insets

I have two plots, say

set multiplot # First plot with inset
plot exp(-x)            
set size 0.6, 0.5     
set origin 0.4, 0.5 
plot cos(x)  
unset multiplot

set multiplot # Second plot with inset
plot exp(-2x)            
set size 0.6, 0.5     
set origin 0.4, 0.5 
plot sin(x)  
unset multiplot

This will create two separate plots, but I really would like a single output with both plots next to each other. As a pseudo-code, I would expect something like

 set multiplot layout 1,2
    set multiplot
    plots+insets of first plot here
    unset multiplot
    set multiplot
    plots+insets of second plot here
    unset multiplot
 unset multiplot

Of course, I dont think you can (easily) nest multiplot like that, so maybe a different approach is necessary? To re-phrase the question: how does one use multiplot to create different plots next to each other so that some of these plots also contain insets (which itself requires the use of multiplot)?

EDIT: as a response to Ethan's comment: The final output is only intended to be a pdf image. I am ok to first create the individual plots and afterwards put them together, however I would like to still be able to position the two images relative to each other. In particular, it should be possible to "fuse" the right border of the first image and the left border of the second image. Within a single multiplot, this can for example be done by modifying the tmargins and bmargins. Can this still be done with separate images?

question from:https://stackoverflow.com/questions/65923375/gnuplot-multiplot-and-insets

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is how I understand your question. I guess you simply need to set the origin and sizes yourself. You can use variables to calculate the necessary values.

Code:

### multiplot with "insets"
reset session

set key top left
set multiplot 

    # settings for main plots
    set ytics auto

    # first plot
    s1x = 0.5
    s1y = 1.0
    set size s1x, s1y
    o1x = 0.0
    o1y = 0.0
    set origin o1x, o1y
    plot exp(-x)
    
    # second plot
    s2x = 0.5
    s2y = 1.0
    set size s2x, s2y
    o2x = 0.5
    o2y = 0.0
    set origin o2x, o2y
    set ytics auto
    plot exp(-2*x)       
    
    # settings for insets
    set ytics 0.5
    
    # first inset
    set size   s1x*0.6, s1y*0.5     
    set origin o1x+s1x*0.4, o1y+s1y*0.5 
    plot cos(x)  

    # second inset
    set size s2x*0.6, s2y*0.5     
    set origin o2x+s2x*0.4, o2y+s2y*0.5 
    plot sin(x)  

unset multiplot
### end of code

Result:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...