
While working on data visualization for the article, it became necessary to have 4 axes with positive labels on all of them.
As with other graphs in the article, I decided to use gnuplot. First, I checked the official website, which has many examples. I was very pleased when I found the needed (a bit of tweaking and it will look nice, I thought).

Quickly copied the code, launched it. I got an error. I looked into it. It turned out that I have an old version of gnuplot (Version 5.0 patchlevel 3 last modified 2016-02-21) and it does not support this functionality.
Knowing about gnuplot's flexibility, I began searching the vastness of the web and stumbled upon several suitable examples on stackoverflow ( and ) and github (). They became the starting point.
Next, my manipulations with the commands led to the following:
0) Disable
unset border
1) Create 4 zero lines — 2 main and 2 additional:
set xzeroaxis
set yzeroaxis
set x2zeroaxis
set y2zeroaxis
A few words about the zero lines in . This operation brings the axes to the center of the plot. The additional lines are needed to display positive ticks on them.
2) Configure the tick display on the axes:
max = 1.5 # For flexibility
min = -max
set xtics axis 0,.5,max in scale 0.5,0.25 mirror norotate autojustify offset 0.35
set ytics axis .5,.5,max in scale 0.5,0.25 mirror norotate autojustify
set x2tics axis .5,.5,max in scale 0.5,0.25 mirror norotate autojustify
set y2tics axis .5,.5,max in scale 0.5,0.25 mirror norotate autojustify
There are a bit more settings for ticks on the axes.
axis — where the ticks will be located, on the axis or (border — on the boundary).
For the axis x, which extends to the right 0,.5,max. The first number is the starting point, the second is the step, and the third is the end point. For the first from 0, and for the others from 0.5, to avoid mixing zeros at the origin.


Mixing zeros at the center of the coordinates.
All intervals *tics are configured as 0,.5,max
Without offset 0.35 for xtics
Settings scale 0.5,0.25 mirror adds ticks to the axis. By adjusting the numbers, their size will change.
I also introduce the variables max, min, with which I control the boundaries of the graph axes.
Additional information on configuring ticks can be found in the documentation under .
3) Configure the axis ranges:
set xrange [ min : max ]
set yrange [ min : max ]
set x2range [ max : min ]
set y2range [ max : min ]
It should be noted that 2 axes start counting from min increasing and 2 axes — from max decreasing.
Additional information can be found in the section .
4) We give names to the axes and arrange them nicely:
set label "H_1" at 0, max center offset char 2, 0
set label "H_2" at max+0.1, 0 center offset char -1, 1
set label "H_3" at 0, min center offset char -2, 0
set label "H_4" at min, 0 center offset char 0, 1
5) We generate the input data
Each graph is allocated 2 columns. The row number indicates the axis, the fifth row is to close the contour. The odd column represents the coordinate x, the even column — y. Since all points are located on the axes, one of the pair (x, y) is always equal to zero.
Despite all 4 axes being positive, some data is artificially moved to the negative half because they are located on the primary axes. x and y.
0 1 0 1.21
1 0 1.21 0
0 -1 0 -1.06
-1 0 -1.19 0
0 1 0 1.21 #Duplicate of the first point
Result

Full Code
#!/usr/bin/gnuplot -persist
#файл в кодировке cp1251 чтоб русские буквы отображались в eps
set encoding cp1251
set terminal postscript eps enhanced monochrome size 5cm,5cm
set output "./img/eps/fig2.eps"
unset border
set key at -2, 1.5 font 'LiberationSerif, 23'
set key left top samplen 4.5
set xzeroaxis
set yzeroaxis
set x2zeroaxis
set y2zeroaxis
max = 1.5
min = -max
set xtics axis 0,.5,max in scale 0.5,0.25 mirror norotate autojustify offset 0.35 font 'LiberationSerif, 20
set ytics axis .5,.5,max in scale 0.5,0.25 mirror norotate autojustify font 'LiberationSerif, 20
set x2tics axis .5,.5,max in scale 0.5,0.25 mirror norotate autojustify font 'LiberationSerif, 20
set y2tics axis .5,.5,max in scale 0.5,0.25 mirror norotate autojustify font 'LiberationSerif, 20
set xrange [ min : max ]
set yrange [ min : max ]
set x2range [ max : min ]
set y2range [ max : min ]
set label "H_1" at 0, max center offset char 2, 0 font 'LiberationSerif, 23'
set label "H_2" at max+0.1, 0 center offset char -1, 1 font 'LiberationSerif, 23'
set label "H_3" at 0, min center offset char -2, 0 font 'LiberationSerif, 23'
set label "H_4" at min, 0 center offset char 0, 1 font 'LiberationSerif, 23'
set style line 1 linetype 1 pointtype 7 linewidth 3 linecolor black
set style line 2 linetype 2 pointtype 7 linewidth 3 linecolor black
plot 'data.csv' using 1:2 title "1" w lp ls 1 ,
'data.csv' using 3:4 title "2" w lp ls 2
Source: habr.com
