Debian Codegraph @

src/colourbar.f90

raw
1 !-----------------------------------------------------------------
2 !
3 ! This file is (or was) part of SPLASH, a visualisation tool
4 ! for Smoothed Particle Hydrodynamics written by Daniel Price:
5 !
6 ! http://users.monash.edu.au/~dprice/splash
7 !
8 ! SPLASH comes with ABSOLUTELY NO WARRANTY.
9 ! This is free software; and you are welcome to redistribute
10 ! it under the terms of the GNU General Public License
11 ! (see LICENSE file for details) and the provision that
12 ! this notice remains intact. If you modify this file, please
13 ! note section 2a) of the GPLv2 states that:
14 !
15 ! a) You must cause the modified files to carry prominent notices
16 ! stating that you changed the files and the date of any change.
17 !
18 ! Copyright (C) 2005-2014 Daniel Price. All rights reserved.
19 ! Contact: [email protected]
20 !
21 !-----------------------------------------------------------------
22
23 !------------------------------------------------------------------------
24 ! Module containing routines related to plotting the colour bar
25 ! in various styles
26 !------------------------------------------------------------------------
27 module colourbar
28 implicit none
29 integer, parameter, public :: maxcolourbarstyles = 12
30 character(len=28), dimension(0:maxcolourbarstyles), parameter, public :: &
31 labelcolourbarstyles = (/'no colour bar ', &
32 'vertical (right hand side) ', &
33 'horizontal (underneath plot)', &
34 'plot-hugging vertical ', &
35 'plot-hugging horizontal ', &
36 'one-sided vertical ', &
37 'one-sided horizontal ', &
38 'floating/inset vertical ', &
39 'floating/inset horizontal ', &
40 'vertical (left hand side) ', &
41 'horizontal (on top) ', &
42 'custom vertical ', &
43 'custom horizontal '/)
44
45 integer, parameter, public :: maxfloatingstyles = 5
46 character(len=*), dimension(maxfloatingstyles), parameter, public :: &
47 labelfloatingstyles = (/' 1) Top left ', &
48 ' 2) Top right ', &
49 ' 3) Bottom left ', &
50 ' 4) Bottom right', &
51 ' 5) Custom '/)
52 !
53 !--these are settings that have default values but can
54 ! be changed if required
55 !
56 real, public :: ColourBarDisp = 5.0
57 real, public :: ColourBarWidth = 2. ! width in character heights
58 logical, public :: iplotcolourbarlabel = .true.
59 logical, public :: ilogcolourbaraxis = .false.
60
61 public :: plotcolourbar,incolourbar,incolourbarlabel,barisvertical
62 public :: get_colourbarmargins,isfloating,adjustcolourbar,iscustombar
63 public :: set_floating_bar_style
64 real, private, save :: xlabeloffsetsave = 0.
65 real, parameter, private :: dispall = 0.25
66 real, public :: ColourBarPosx = 0.01 ! default x pos of short/fat bars
67 real, public :: ColourBarPosy = 0.05 ! default y pos of short/fat bars
68 real, public :: ColourBarLen = 0.25 ! default length of short/fat bars
69 character(len=10), public :: ColourBarFmtStr = 'BCMSTV '
70 private
71
72 contains
73
74 !--------------------------------------------------------
75 ! this subroutine plots the colour bar in various styles
76 !--------------------------------------------------------
77 subroutine plotcolourbar(istyle,icolours,datmin,datmax,label,log, &
78 xlabeloffset,vptxminfull,vptxmaxfull,vptyminfull,vptymaxfull)
79 use plotlib, only:plot_set_exactpixelboundaries,plotlib_is_pgplot
80 use plotlib, only:plot_bbuf,plot_ebuf,plot_qwin,plot_qvp,plot_qcs,&
81 plot_svp,plot_swin,plot_imag,plot_box,plot_annotate,plot_gray,&
82 plotlib_extend_pad
83 integer, intent(in) :: istyle,icolours
84 real, intent(in) :: datmin,datmax,xlabeloffset
85 character(len=*), intent(in) :: label
86 logical, intent(in) :: log
87 real, intent(in), optional :: vptxminfull,vptxmaxfull,vptyminfull,vptymaxfull
88 integer, parameter :: maxpixwedg = 400
89 real, dimension(6), parameter :: trans = (/-0.5,1.0,0.0,-0.5,0.0,1.0/)
90 real, dimension(1,maxpixwedg) :: sampley
91 real, dimension(maxpixwedg,1) :: samplex
92 character(len=1) :: logc
93 integer :: i,npixwedg
94 real :: disp,width,xch,ych,dx
95 real :: xmin,xmax,ymin,ymax,vptxmin,vptxmax,vptymin,vptymax
96 real :: vptxmini,vptxmaxi,vptymini,vptymaxi
97 real :: vptxminp,vptxmaxp,vptyminp,vptymaxp
98 real :: xmaxpix,xminpix,yminpix,ymaxpix
99 !
100 !--return on style 0
101 !
102 if (istyle <= 0) return
103 !
104 !--set colour bar displacement and width in character heights
105 !
106 width = ColourBarWidth
107 xlabeloffsetsave = xlabeloffset
108 !
109 !--start buffering
110 !
111 call plot_bbuf
112 !
113 !--query and save current viewport, page and character height settings
114 !
115 call plot_qwin(xmin,xmax,ymin,ymax)
116 call plot_qvp(0,vptxmin,vptxmax,vptymin,vptymax)
117 call plot_qcs(0,xch,ych)
118
119 !--if colour bar stretches across multiple plots,
120 ! override settings for vptymin and vptymax with input values
121 if (present(vptxminfull) .and. present(vptxmaxfull) .and. &
122 present(vptyminfull) .and. present(vptymaxfull)) then
123 vptxmini = vptxminfull
124 vptxmaxi = vptxmaxfull
125 vptymini = vptyminfull
126 vptymaxi = vptymaxfull
127 else
128 vptxmini = vptxmin
129 vptxmaxi = vptxmax
130 vptymini = vptymin
131 vptymaxi = vptymax
132 endif
133 disp = dispall
134
135 select case(istyle)
136 !------------------------
137 ! horizontal colour bar
138 !------------------------
139 case(2,4,6,8,10,12)
140
141 if (istyle==4) disp = 0. ! plot-hugging
142 !
143 !--set viewport for the wedge
144 !
145 if (isfloating(istyle)) then
146 vptxminp = vptxmini ! to
147 vptxmaxp = vptxmaxi ! avoid
148 vptyminp = vptymini ! compiler
149 vptymaxp = vptymaxi ! warnings
150 call barlimits(vptxmini,vptxmaxi,vptxminp,vptxmaxp,ColourBarPosx,ColourBarLen)
151 call barlimits(vptymini,vptymaxi,vptyminp,vptymaxp,ColourBarPosy,ColourBarLen)
152 vptymaxi = vptymini + width*ych
153 elseif (istyle==10) then
154 ! on top of plot
155 vptymini = vptymaxi + (disp+0.1)*ych
156 vptymaxi = vptymini + width*ych
157 else
158 vptymaxi = vptymini - (disp + xlabeloffset)*ych
159 vptymini = vptymaxi - width*ych
160 endif
161 call plot_svp(vptxmini,vptxmaxi,vptymini,vptymaxi)
162 call plot_set_exactpixelboundaries()
163 !--check number of pixels in colour bar
164 call plot_qvp(3,xminpix,xmaxpix,yminpix,ymaxpix)
165 npixwedg = max(min(int(xmaxpix-xminpix),maxpixwedg),2)
166 !
167 !--fill array with all values from datmin to datmax
168 !
169 dx = (datmax-datmin)/real(npixwedg-1)
170 do i=1,npixwedg
171 samplex(i,:) = datmin + (i-1)*dx
172 enddo
173 !
174 !--draw colour bar, by cleverly setting window size
175 !
176 call plot_swin(1.0,real(npixwedg),0.0,1.0)
177
178 if (abs(icolours) > 0) then ! colour
179 !--check if the colour bar will be more than 1024 pixels
180 if ((xmaxpix-xminpix) <= 1024 .or. .not.plotlib_is_pgplot) then
181 !
182 !--the standard way is to use the default line below
183 !
184 if (icolours==1) then
185 call plot_gray(samplex,npixwedg,1,1,npixwedg,1,1,datmin,datmax,trans,iextend=plotlib_extend_pad)
186 else
187 call plot_imag(samplex,npixwedg,1,1,npixwedg,1,1,datmin,datmax,trans,iextend=plotlib_extend_pad)
188 endif
189 else
190 !
191 !--if > 1024 pixels, we instead use the following:
192 ! this is a workaround for a PGPLOT bug with large colour bars
193 ! (> 1024 device pixels long) - plot colour bar in two halves.
194 ! this works up to 2048 pixels, really should divide by n.
195 !
196 call plot_svp(vptxmini,vptxmaxi-0.5*(vptxmaxi-vptxmini),vptymini,vptymaxi)
197 call plot_swin(1.0,real(npixwedg/2),0.0,1.0)
198 call plot_set_exactpixelboundaries()
199 call plot_imag(samplex,npixwedg,1,1,npixwedg/2,1,1,datmin,datmax,trans)
200
201 call plot_svp(vptxmaxi-0.5*(vptxmaxi-vptxmini)-0.001,vptxmaxi,vptymini,vptymaxi)
202 call plot_swin(real(npixwedg/2 + 1),real(npixwedg),0.0,1.0)
203 call plot_set_exactpixelboundaries()
204 call plot_imag(samplex,npixwedg,1,npixwedg/2+1,npixwedg,1,1,datmin,datmax,trans)
205 call plot_svp(vptxmini,vptxmaxi,vptymini,vptymaxi)
206 call plot_set_exactpixelboundaries()
207 endif
208 endif
209 call plot_swin(datmin,datmax,0.0,1.0)
210 !
211 !--draw labelled frame around the wedge
212 !
213 if (istyle==12) then
214 call plot_box(ColourBarFmtStr,0.0,0,'BC',0.0,0)
215 elseif (istyle==10) then
216 call plot_box('BCSMT',0.0,0,'BC',0.0,0)
217 elseif (istyle==4 .or. istyle==6 .or. istyle==8) then
218 call plot_box('BNST',0.0,0,'BC',0.0,0)
219 if (istyle==6 .or. istyle==8) call plot_box('C',0.0,0,' ',0.0,0)
220 else
221 call plot_box('BCNST',0.0,0,'BC',0.0,0)
222 endif
223 !
224 !--write the units label: the position is relative to the bottom of
225 ! the wedge because of the way we have defined the viewport.
226 ! For the horizontal colour bar this never needs to change
227 ! (0.25 space + 1 character height for numeric labels + 0.25 space
228 ! + 1 character height for actual label = 2.5 character heights)
229 !
230 if (len_trim(label) > 0 .and. iplotcolourbarlabel) then
231 if (istyle==10) then
232 call plot_annotate('T',2.5,0.5,0.5,trim(label))
233 else
234 call plot_annotate('B',2.5,0.5,0.5,trim(label))
235 endif
236 endif
237
238 !-------------------------------
239 ! vertical colour bar (default)
240 !-------------------------------
241 case default
242 if (istyle==3) disp = 0. ! plot-hugging
243 !
244 !--set viewport for the wedge
245 !
246 if (isfloating(istyle)) then
247 vptxminp = vptxmini ! to
248 vptxmaxp = vptxmaxi ! avoid
249 vptyminp = vptymini ! compiler
250 vptymaxp = vptymaxi ! warnings
251 call barlimits(vptxmini,vptxmaxi,vptxminp,vptxmaxp,ColourBarPosx,ColourBarLen)
252 call barlimits(vptymini,vptymaxi,vptyminp,vptymaxp,ColourBarPosy,ColourBarLen)
253 vptxmaxi = vptxmini + width*xch
254 elseif (istyle==9) then
255 vptxmaxi = vptxmini - disp*xch
256 vptxmini = vptxmaxi - width*xch
257 else
258 vptxmini = vptxmaxi + disp*xch
259 vptxmaxi = vptxmini + width*xch
260 endif
261 call plot_svp(vptxmini,vptxmaxi,vptymini,vptymaxi)
262 call plot_set_exactpixelboundaries()
263
264 !--check number of pixels in colour bar
265 call plot_qvp(3,xminpix,xmaxpix,yminpix,ymaxpix)
266 npixwedg = max(min(int(ymaxpix-yminpix),maxpixwedg),2)
267 dx = (datmax-datmin)/real(npixwedg-1)
268 do i=1,npixwedg
269 sampley(:,i) = datmin + (i-1)*dx
270 enddo
271 !
272 !--use log ticks
273 !
274 logc = ''
275 if (ilogcolourbaraxis) logc = 'L'
276 !
277 !--draw colour bar, by cleverly setting window size
278 !
279 call plot_swin(0.0,1.0,0.0,real(npixwedg))
280 if (icolours==1) then ! greyscale
281 call plot_gray(sampley,1,npixwedg,1,1,1,npixwedg,datmin,datmax,trans,iextend=plotlib_extend_pad)
282 elseif (abs(icolours) > 0) then ! colour
283 call plot_imag(sampley,1,npixwedg,1,1,1,npixwedg,datmin,datmax,trans,iextend=plotlib_extend_pad)
284 endif
285 call plot_swin(0.0,1.0,datmin,datmax)
286 !
287 !--draw labelled frame around the wedge
288 !
289 if (istyle==11) then
290 call plot_box('BC',0.0,0,ColourBarFmtStr,0.0,0)
291 elseif (istyle==9) then
292 call plot_box('BC',0.0,0,'BCNSTV',0.0,0)
293 elseif (istyle==3 .or. istyle==5 .or. istyle==7) then
294 call plot_box('BC',0.0,0,'CMSTV',0.0,0)
295 if (istyle==5 .or. istyle==7) call plot_box(' ',0.0,0,'B',0.0,0)
296 else
297 call plot_box('BC',0.0,0,'BCMSTV'//logc,0.0,0)
298 endif
299 !
300 !--write the units label: the position is relative to the edge of
301 ! the wedge because of the way we have defined the viewport.
302 ! For the vertical colour bar ColourBarDisp is a set by default to
303 ! the maximum size for the numeric label (written horizontally) -
304 ! this is about 4 character heights for something like "-5 x 10^10"
305 ! We allow the user to adjust this parameter to bring the label
306 ! closer where the numeric labels are smaller (e.g. "-5").
307 !
308 if (len_trim(label) > 0 .and. iplotcolourbarlabel) then
309 if (istyle==9) then
310 call plot_annotate('L',ColourBarDisp+0.75,1.0,1.0,trim(label))
311 else
312 call plot_annotate('R',ColourBarDisp+0.75,1.0,1.0,trim(label))
313 endif
314 endif
315 end select
316 !
317 !--reset window and viewport
318 !
319 call plot_svp(vptxmin,vptxmax,vptymin,vptymax)
320 call plot_swin(xmin,xmax,ymin,ymax)
321 call plot_ebuf
322
323 return
324 end subroutine plotcolourbar
325
326 !-------------------------------------------------------
327 ! query function to see if colour bar is plotted
328 ! vertically or horizontally for a given style
329 !-------------------------------------------------------
330 logical function barisvertical(istyle)
331 integer, intent(in) :: istyle
332
333 barisvertical = .true.
334 if (istyle <= 0) return
335
336 select case(istyle)
337 case(2,4,6,8,10,12)
338 barisvertical = .false.
339 case default
340 barisvertical = .true.
341 end select
342
343 end function barisvertical
344
345 !-------------------------------------------------------
346 ! query function to see if a given position on
347 ! the plot should lie within the colour bar or not
348 !-------------------------------------------------------
349 logical function incolourbar(istyle,iunits,xpt,ypt,xmin,xmax,ymin,ymax)
350 use plotlib, only:plot_qcs
351 integer, intent(in) :: istyle,iunits
352 real, intent(in) :: xpt,ypt,xmin,xmax,ymin,ymax
353 real :: xminbar,xmaxbar,yminbar,ymaxbar,xch,ych,barwidth
354
355 incolourbar = .false.
356 if (istyle <= 0) return
357
358 select case(istyle)
359 case(8,12)
360 call barlimits(xminbar,xmaxbar,xmin,xmax,ColourBarPosx,ColourBarLen)
361 call barlimits(yminbar,ymaxbar,ymin,ymax,ColourBarPosy,ColourBarLen)
362 call plot_qcs(iunits,xch,ych)
363 ymaxbar = yminbar + 2.*ColourBarWidth*ych
364 if (iplotcolourbarlabel) then
365 yminbar = yminbar - 3.0*ych
366 else
367 yminbar = yminbar - 2.0*ych
368 endif
369 if ((xpt >= xminbar .and. xpt <= xmaxbar) .and. &
370 (ypt >= yminbar .and. ypt <= ymaxbar)) then
371 incolourbar = .true.
372 endif
373 case(7,11)
374 call barlimits(xminbar,xmaxbar,xmin,xmax,ColourBarPosx,ColourBarLen)
375 call barlimits(yminbar,ymaxbar,ymin,ymax,ColourBarPosy,ColourBarLen)
376 call plot_qcs(iunits,xch,ych)
377 if (iplotcolourbarlabel) then
378 barwidth = (2.*ColourBarWidth+0.75 + max(ColourBarDisp+0.75,0.0))*xch
379 else
380 barwidth = (2.*ColourBarWidth+0.75 + 5.0)*xch
381 endif
382 xmaxbar = xminbar + barwidth
383 if ((xpt >= xminbar .and. xpt <= xmaxbar) .and. &
384 (ypt >= yminbar .and. ypt <= ymaxbar)) then
385 incolourbar = .true.
386 endif
387 case(9) ! colour bar on left
388 if (xpt < xmin) incolourbar = .true.
389 case(10) ! colour bar on top
390 if (ypt > ymax) incolourbar = .true.
391 case(2,4,6)
392 if (ypt < ymin) incolourbar = .true.
393 case default
394 if (xpt > xmax) incolourbar = .true.
395 end select
396
397 return
398 end function incolourbar
399
400 !-------------------------------------------------------
401 ! query function to see if a given position on
402 ! the plot should lie within the colour bar label or not
403 !-------------------------------------------------------
404 logical function incolourbarlabel(istyle,iunits,xpt,ypt,xmin,xmax,ymin,ymax)
405 use plotlib, only:plot_qcs
406 integer, intent(in) :: istyle,iunits
407 real, intent(in) :: xpt,ypt,xmin,xmax,ymin,ymax
408 real :: xch,ych,disp,xminbar,xmaxbar,yminbar,ymaxbar
409
410 incolourbarlabel = .false.
411 if (iplotcolourbarlabel) then
412 call plot_qcs(iunits,xch,ych)
413 disp = dispall
414 if (istyle==3 .or. istyle==4) disp = 0.
415 select case(istyle)
416 case(8,12)
417 call barlimits(xminbar,xmaxbar,xmin,xmax,ColourBarPosx,ColourBarLen)
418 if (ypt < (ymin-(disp + xlabeloffsetsave + ColourBarWidth+2.0)*ych) .and. &
419 ypt > (ymin-(disp + xlabeloffsetsave + ColourBarWidth+3.0)*ych) .and. &
420 xpt > xminbar .and. xpt < xmaxbar) incolourbarlabel = .true.
421 case(7,11)
422 call barlimits(yminbar,ymaxbar,ymin,ymax,ColourBarPosy,ColourBarLen)
423 if (xpt > (xmax+(disp + ColourBarWidth-0.25 + max(ColourBarDisp-0.25,0.0))*xch) .and. &
424 xpt < (xmax+(disp + ColourBarWidth+0.75 + max(ColourBarDisp+0.75,0.0))*xch) .and. &
425 ypt > yminbar .and. ypt < ymaxbar) incolourbarlabel = .true.
426 case(2,4,6)
427 if (ypt < (ymin-(disp + xlabeloffsetsave + ColourBarWidth+2.0)*ych) .and. &
428 ypt > (ymin-(disp + xlabeloffsetsave + ColourBarWidth+3.0)*ych)) incolourbarlabel = .true.
429 case(9)
430 if (xpt < (xmin-(disp + ColourBarWidth-0.25 + max(ColourBarDisp-0.25,0.0))*xch) .and. &
431 xpt > (xmin-(disp + ColourBarWidth+0.75 + max(ColourBarDisp+0.75,0.0))*xch)) incolourbarlabel = .true.
432 case(10)
433 if (ypt > (ymax+(disp + xlabeloffsetsave + ColourBarWidth+2.0)*ych) .and. &
434 ypt < (ymax+(disp + xlabeloffsetsave + ColourBarWidth+3.0)*ych)) incolourbarlabel = .true.
435 case default
436 if (xpt > (xmax+(disp + ColourBarWidth-0.25 + max(ColourBarDisp-0.25,0.0))*xch) .and. &
437 xpt < (xmax+(disp + ColourBarWidth+0.75 + max(ColourBarDisp+0.75,0.0))*xch)) incolourbarlabel = .true.
438 end select
439 endif
440
441 return
442 end function incolourbarlabel
443
444 !------------------------------------------
445 ! utility function to avoid repeated code
446 !------------------------------------------
447 subroutine barlimits(barmin,barmax,posmin,posmax,pos,barlen)
448 real, intent(out) :: barmin,barmax
449 real, intent(in) :: posmin,posmax,pos,barlen
450 real :: dpos
451
452 dpos = (posmax - posmin) ! in case posmin and barmin are same variable
453 barmin = posmin + pos*dpos
454 barmax = barmin + barlen*dpos
455
456 end subroutine barlimits
457
458 !-------------------------------------------------------
459 ! query function to get margins which should
460 ! be allowed on the page in order to later plot
461 ! the colour bar
462 !-------------------------------------------------------
463 subroutine get_colourbarmargins(istyle,xminmargin,xmaxmargin,yminmargin,ymaxmargin,barwidth)
464 use plotlib, only:plot_qcs,plot_qvp
465 integer, intent(in) :: istyle
466 real, intent(inout) :: xminmargin,xmaxmargin,yminmargin,ymaxmargin
467 real, intent(out) :: barwidth
468 real :: xch,ych,vptxmin,vptxmax,vptymin,vptymax
469
470 barwidth = 0.
471 if (istyle <= 0) return
472 call plot_qcs(0,xch,ych)
473 call plot_qvp(0,vptxmin,vptxmax,vptymin,vptymax)
474
475 if (barisvertical(istyle)) then
476 if (iplotcolourbarlabel) then
477 barwidth = (ColourBarWidth+0.75 + max(ColourBarDisp+0.75,0.0))*xch
478 else
479 barwidth = (ColourBarWidth+0.75 + 5.0)*xch
480 endif
481 if (isfloating(istyle)) then
482 barwidth = max((ColourBarPosx-1.) + barwidth,0.)
483 endif
484 if (istyle==9) then
485 xminmargin = xminmargin + barwidth
486 else
487 xmaxmargin = xmaxmargin + barwidth
488 endif
489 else
490 if (iplotcolourbarlabel) then
491 barwidth = (ColourBarWidth+3.0)*ych ! ie. width + 2.5 + 0.5 margin
492 else
493 barwidth = (ColourBarWidth+2.0)*ych ! ie. width + 1.5 + 0.5 margin
494 endif
495 if (isfloating(istyle)) then
496 barwidth = max(-(ColourBarPosy - (barwidth - ColourBarWidth*ych)),0.)
497 endif
498 if (istyle==10) then
499 ymaxmargin = ymaxmargin + barwidth + 0.35*ych
500 else
501 yminmargin = yminmargin + barwidth
502 endif
503 endif
504
505 return
506 end subroutine get_colourbarmargins
507
508 !-------------------------------------------------------
509 ! query function for floating colour bar styles
510 !-------------------------------------------------------
511 logical function isfloating(istyle)
512 integer, intent(in) :: istyle
513
514 select case(istyle)
515 case(7,8,11,12)
516 isfloating = .true.
517 case default
518 isfloating = .false.
519 end select
520
521 end function isfloating
522
523 !-------------------------------------------------------
524 ! query function for custom colour bar styles
525 !-------------------------------------------------------
526 logical function iscustombar(istyle)
527 integer, intent(in) :: istyle
528
529 if (istyle==12 .or. istyle==11) then
530 iscustombar = .true.
531 else
532 iscustombar = .false.
533 endif
534
535 end function iscustombar
536
537 !---------------------------------------------------------------------
538 ! utility function used when interactively changing colour bar limits
539 !---------------------------------------------------------------------
540 subroutine adjustcolourbar(istyle,xpt1,ypt1,xpt2,ypt2,&
541 xmin,xmax,ymin,ymax,barmin,barmax)
542 integer, intent(in) :: istyle
543 real, intent(in) :: xpt1,ypt1,xpt2,ypt2,xmin,xmax,ymin,ymax
544 real, intent(inout) :: barmin,barmax
545 real :: dbar,xminbar,xmaxbar,yminbar,ymaxbar
546
547 if (istyle==8 .or. istyle==12) then
548 !--floating horizontal bar
549 xminbar = xmin + ColourBarPosx*(xmax - xmin)
550 xmaxbar = xminbar + ColourBarLen*(xmax - xmin)
551 else
552 xminbar = xmin
553 xmaxbar = xmax
554 endif
555 if (istyle==7 .or. istyle==11) then
556 !--floating vertical bar
557 yminbar = ymin + ColourBarPosy*(ymax - ymin)
558 ymaxbar = yminbar + ColourBarLen*(ymax - ymin)
559 else
560 yminbar = ymin
561 ymaxbar = ymax
562 endif
563
564 if (barisvertical(istyle)) then
565 if ((ymaxbar-yminbar) > 0.) then
566 dbar = (barmax-barmin)/(ymaxbar-yminbar)
567 else
568 dbar = 0.
569 endif
570 barmax = barmin + (max(ypt1,ypt2)-yminbar)*dbar
571 barmin = barmin + (min(ypt1,ypt2)-yminbar)*dbar
572 else
573 if ((xmaxbar-xminbar) > 0.) then
574 dbar = (barmax-barmin)/(xmaxbar-xminbar)
575 else
576 dbar = 0.
577 endif
578 barmax = barmin + (max(xpt1,xpt2)-xminbar)*dbar
579 barmin = barmin + (min(xpt1,xpt2)-xminbar)*dbar
580 endif
581
582 end subroutine adjustcolourbar
583
584 subroutine set_floating_bar_style(iColourBarStyle,iColourBarPos)
585 integer, intent(in) :: iColourBarStyle,iColourBarPos
586
587 select case(iColourBarPos)
588 case(1)
589 if (barisvertical(iColourBarStyle)) then
590 ColourBarPosx = 0.01
591 ColourBarPosy = 0.74
592 else
593 ColourBarPosx = 0.01
594 ColourBarPosy = 0.95
595 endif
596 case(2)
597 if (barisvertical(iColourBarStyle)) then
598 ColourBarPosx = 0.82 ! minus width in ch
599 ColourBarPosy = 0.74
600 else
601 ColourBarPosx = 0.73
602 ColourBarPosy = 0.95
603 endif
604 case(3)
605 if (barisvertical(iColourBarStyle)) then
606 ColourBarPosx = 0.01
607 ColourBarPosy = 0.01
608 else
609 ColourBarPosx = 0.015
610 ColourBarPosy = 0.075
611 endif
612 case(4)
613 if (barisvertical(iColourBarStyle)) then
614 ColourBarPosx = 0.82 ! minus width in ch
615 ColourBarPosy = 0.01
616 else
617 ColourBarPosx = 0.73
618 ColourBarPosy = 0.075
619 endif
620 end select
621
622 end subroutine set_floating_bar_style
623
624 end module colourbar