Search code examples
gnuplotaxis

Gnuplot. tics on axis and border. Number only on border


working on my thesis here.

I've been trying to plot with tics on the border and the zero axes. I just want to have numbers on the border.

The result expected should be as if the 2 images attached were combined.

enter image description hereenter image description here

Is there any way to do this?

Code First image:

set xtics axis        
set ytics axis 
set format x ""
set format y ""
set xzeroaxis linetype -1
set yzeroaxis linetype -1  
set tics in scale 1
set mxtics 2
set mytics 2
set xtics mirror
set ytics mirror

Code Second image:

set xtics border        
set ytics border
set format x "% g"
set format y "% g" 
unset xzeroaxis
unset yzeroaxis
set tics in scale 2.5
set mxtics 5
set mytics 2
set xtics mirror
set ytics mirror

Thanks!!!


Solution

  • As I understand the documentation (check help xtics) you can have the tics either at the axis or at the border but not both.

    set xtics {axis | border} {{no}mirror} ...
    

    A quick and dirty solution would be using multiplot. You need to fix the margins to get the plots exactly on top of each other. Check the following example as starting point, maybe there are smarter solutions.

    Code:

    ### having tics at the border AND axis
    reset session
    set xrange [-0.4:0.4]
    set xtics 0.1 border
    set mxtics 5
    
    set yrange [-1:1]
    set ytics 0.2 border
    set mytics 2
    
    set xzeroaxis linetype -1
    set yzeroaxis linetype -1 
    set tics in scale 1
    
    set margins 10,10,3,3   # <left>, <right>, <bottom>, <top>
    set key noautotitle
    
    set multiplot
        plot sin(12*x)
    
        set xtics axis
        set format x ''
        set ytics axis
        set format y ''
        plot NaN        # dummy plot
    unset multiplot
    ### end of code
    

    Result:

    enter image description here