Colorbox position and size

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Colorbox position and size

Martin Ward

I am plotting some 2D data (a heatmap) which needs to be "pixel perfect"
and include a colorbox. I want no margins, so I use "set lmargin 0" etc.
I can then set the terminal size to the exact size of the plot,
with an extra margin for the colorbox. But the top and bottom
numbers in the colorbox are clipped.

I need to shrink the colorbox, so that it is not clipped,
but get it to be placed to the right of the plot.

I can only change the size and origin of the colorbox using
the "user" option: which also causes plot to be expanded to
the full width of the image, with the colorbox placed on top of it.

This plot file illustrates the problem:

################### gnuplot example #####################
set lmargin 0
set rmargin 0
set tmargin 0
set bmargin 0
set terminal png size 318,256
set out 'out.png'

# By default, the box is to the right of the plot
# but the numbers are clipped top and bottom.
#
# If we uncomment this line, the box moves over the plot
# and is clipped on the right. The plot is wider:
#set colorbox user

# If we uncomment this line, the box is smaller and not clipped,
# but is still over the plot, and the plot is wider:
#set colorbox user size 0.05,0.8 origin 0.8,0.1

plot[0:1][0:1] '-' u 1:2:3 with image
0 0 0
0 1 1
1 0 2
1 1 3
e
################# end of example ######################

--
                        Martin

Dr Martin Ward STRL Principal Lecturer & Reader in Software Engineering
[hidden email]  http://www.cse.dmu.ac.uk/~mward/  Erdos number: 4
G.K.Chesterton web site: http://www.cse.dmu.ac.uk/~mward/gkc/
Mirrors:  http://www.gkc.org.uk  and  http://www.gkc.org.uk/gkc

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|

Re: Colorbox position and size

theozh

set rmargin manually in screen coordinates such that you get a squared
graph. For this, it might be convenient to define variables "PlotWidth"
and "PlotHeight".
In the code below I added a "control" graph in the wxt terminal. Skip
the lines if you don't need it.


Apart from this: a question from my side to the gnuplot-experts:
If I leave out the decimal points in the definition for PlotWidth and
PlotHeight, I will get an empty graph because the (integer) division is
obviously zero and as a consequence rmargin is set at screen 0. If I
anyway load the same gnuplot code a second time, gnuplot crashes/ends
immediately. Is this a bug or a feature?


################### gnuplot example #####################
reset

set terminal png size PlotWidth,PlotHeight font "Arial,10"
set output 'out.png'

PlotWidth=318.  # decimal point to avoid integer division
PlotHeight=256. # see above

set lmargin 0
set rmargin at screen (PlotHeight/PlotWidth)
set tmargin 0
set bmargin 0

set colorbox user size 0.05,0.8 origin 0.85,0.1

plot[0:1][0:1] '-' u 1:2:3 with image
0 0 0
0 1 1
1 0 2
1 1 3
e

set output
set term wxt size PlotWidth,PlotHeight
replot

################# end of example ######################


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|

Re: Colorbox position and size

theozh

sorry,
of course, the definition of the variables has to come first.


PlotWidth=318. # decimal point to avoid integer division
PlotHeight=256. # see above

set terminal png size PlotWidth,PlotHeight font "Arial,10"
set output 'out.png'

...


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|

Re: Colorbox position and size

Martin Ward
In reply to this post by theozh
On 21/04/16 13:01, theozh wrote:
> set rmargin manually in screen coordinates such that you get a squared
> graph. For this, it might be convenient to define variables "PlotWidth"
> and "PlotHeight".

That does the trick, thanks!

For some reason I didn't think of setting a right margin and moving
the colorbox into it!  Also: thanks for the tip about defining
variables and putting a decimal point into the numbers to ensure
floating point computations.

--
                        Martin

Dr Martin Ward STRL Principal Lecturer & Reader in Software Engineering
[hidden email]  http://www.cse.dmu.ac.uk/~mward/  Erdos number: 4
G.K.Chesterton web site: http://www.cse.dmu.ac.uk/~mward/gkc/
Mirrors:  http://www.gkc.org.uk  and  http://www.gkc.org.uk/gkc

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info