Bernhard
Bernhard

Reputation: 3694

Labels of cbtics on opposite side of horizontal colorbox

Suppose I have the following script to make a sort of contourplot.

set colorbox horizontal user origin 0.1, 0.9 size 0.8, 0.05
set pm3d map
splot x*y

This gives the below result.

Sample image

Now, what I want to achieve, is that the ticklabels automatically end up on the opposite site of the colorbox. How can I do that?

I tried:

My gnuplot version is 4.6.2

Upvotes: 7

Views: 4030

Answers (1)

theozh
theozh

Reputation: 25724

Here is a kind of cumbersome workaround using multiplot. It's a bit lengthy, but at least, fiddling around in order to find the proper cbtics label offsets when changing the canvas size should be eliminated. It works with gnuplot 4.6 (time of the OP's question). With current gnuplot versions it might look slightly different, but can be tuned with the parameters CBHeight, CBWidth, CBPosX, CBPosY.

Possible improvements: I haven't found yet how to automatically make the colorbox, e.g. the same width as the graph and center it to the graph by using the GPVAL_... variables.

Code:

### horizontal color bar with xtics on top
reset

set multiplot 

    # actual plot
    unset colorbox
    set size square
    set pm3d map
    set isosamples 100
    set samples 100
    splot sin(1.3*x)*cos(.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x) notitle

    # horizontal "pseudo" colorbar with tic labels on top 
    # size of colorbox in screen coordinates
    CBHeight = 0.04
    CBWidth  = 0.49
    CBPosX   = (1 - CBWidth)/2   # centered
    CBPosY   = 0.87
    set origin CBPosX,CBPosY
    set size nosquare CBWidth,CBHeight
    set lmargin 0; set tmargin 0; set rmargin 0; set bmargin 0
    unset pm3d
    unset tics
    unset key
    set x2tics out nomirror scale 1.0,0 offset 0,0 
    set colorbox horizontal user origin graph 0, graph 0 size graph 1, graph 1
    set xrange [GPVAL_CB_MIN:GPVAL_CB_MAX]
    plot x palette  # dummy plot
    
unset multiplot
### end of code

Result: (generated with gnuplot 4.6.0)

enter image description here

Upvotes: 2

Related Questions