Skip to content

Commit

Permalink
(feature)(example) Added Example 109 with zlim usage with a workaroun…
Browse files Browse the repository at this point in the history
…d to `cbrange` issue
  • Loading branch information
14NGiestas committed May 4, 2022
1 parent 730dd80 commit 4f1d604
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion example/demo.f90
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ program demo
print*, "Example 106: Multiplot layout in 3D"
print*, "Example 107: Multiplot layout for 3D data"
print*, "Example 108: Plot a 2D grid"
print*, "Example 109: Plot a 2D grid with random data, but use zlim to select a zrange"

print*
write (unit=*, fmt='(a)') "2D plots: select an example: 1 through 30"
write (unit=*, fmt='(a)') "3D plots: select an example: 101 through 108"
write (unit=*, fmt='(a)') "3D plots: select an example: 101 through 109"
write (unit=*, fmt='(a)', advance='no') "enter 0 for exit: "
read*, i

Expand Down Expand Up @@ -226,6 +227,8 @@ program demo
call exmp107
case(108)
call exmp108
case(109)
call exmp109


case (0)
Expand Down Expand Up @@ -1479,4 +1482,39 @@ subroutine exmp108
end subroutine exmp108


!...............................................................................
!Example 109: Plot a 2D grid with random data, but use zlim to select a zrange
!...............................................................................
subroutine exmp109()
type(gpf):: gp
integer, parameter:: n=100

real(wp), allocatable:: x(:,:)
real(wp), allocatable:: y(:,:)
real(wp), allocatable:: z(:,:)

! create the xyz data
call meshgrid(x,y,linspace(-1.5_wp,1.5_wp,n))
allocate(z(n,n))
! fills with random numbers
call random_number(z)
! make them between -1.0_wp and 1.0_wp
z = z - 2.0_wp*z
! create regions outsize such range
z = merge(-2.0_wp, z, x >= -.2_wp .and. x <= .2_wp)
z = merge(-2.0_wp, z, y >= -.2_wp .and. y <= .2_wp)

!plot the contour
call gp%title('Example 109: Zlim Example')
call gp%options('unset border') ! turn off border line (axes)
call gp%options('set view map')
! Anything outside -1.0_wp and 1.0_wp will be cut off
call gp%zlim([-1.0_wp,1.0_wp])
call gp%options('set cbrange[-1.0:1.0]')
call gp%surf(x,y,z,palette='set1')

end subroutine exmp109



end program demo

0 comments on commit 4f1d604

Please sign in to comment.