Silverfrost Forums

Welcome to our forums

Set tight axis limits

8 Jan 2024 2:42 #30943

Hello

Quick query. How do you set tight limits on an axis? Currently a plot goes from 0 to 105 on x-axis but I need it to be tight in the range 0-100. An example code would be useful.

Thanks

Lester

8 Jan 2024 4:42 #30944

arctica

Please post the code that needs to be refined.

8 Jan 2024 4:49 #30945

Here is the code

program Riemann_Zeta

  use clrwin
  integer :: iw

  integer, parameter :: k = 10001
  integer, allocatable :: t(:)
  real, allocatable :: vec(:)
  real, dimension(k) :: zeta
  integer :: i, j, n, im, export_cb
  real :: real_part(k), imaginary_part(k), start, finish, a, inc
  complex :: s(k)
  external :: export_cb

  call clock@(start)

  open(25,file='complex_zeta.csv',status='replace')
  
  t=(/0, (i,i=1,k)/)

  a = 0.    ! initial value
  inc = 0.01 ! increment value
  n = 10001   ! number of values  
  allocate(vec(n))
  vec = [(a + (i-1) * inc, i=1,n)]  ! array constructor

  do j = 1, k
     s(j) = cmplx(0.5,vec(j)) ! Generate array of complex numbers (0-100)
  end do

     zeta = zeta_3(s,10000) ! Compute complex Zeta function values

  real_part = real(zeta_3(s,10000))
  imaginary_part = aimag(zeta_3(s,10000))

  !do i = 1, k
  write(25,'(f15.12,',',f15.12,',',f15.12)') (real_part(i), imaginary_part(i), vec(i), i=1,k) ! write data to csv file
  !end do

  close(25)
  call clock@(finish)

  print *, zeta_3(cmplx(0.5,1.0),10000) ! complex number fixed value

  print *, 'Processing time was ', finish-start, ' seconds'

  iw = winio@('%mn[Exit]&','Exit')
  iw = winio@('%mn[Export]&',export_cb)
  iw = winio@('%fn[Times New Roman]%ts%bf&',1.5d0)
  call winop@('%pl[native,x_array,frame,gridlines,width=1.5,link=curves,colour=red,colour=blue]')
  call winop@('%pl[xaxis='Real(t)',yaxis='Zeta(s)']')
  call winop@('%pl[Title='Riemann Zeta function (s = 0.5 + i*t)']')
  iw = winio@('%pl&',1400,800,k,dble(vec),dble(real_part),dble(imaginary_part))
  !iw=winio@('%PL[file=testplot.jpg, N_GRAPHS=1]', 1000, 800, k, dble(real_part), dble(imaginary_part))
  iw = winio@('')

contains
  
elemental function zeta_3(s,n) result(zs1)
   integer,allocatable :: nn(:)
   integer, intent(in) :: n
   complex zs1
   complex, intent(in) :: s
   allocate (nn(n))
   nn = (/(i,i=1,n)/)
   zs1 = sum((-1)**(nn + 1)/(nn**s ))
   zs1 = 1/(1 - 2**( 1-s ))*zs1
end function zeta_3

end program

integer function export_cb()
use clrwin
  im = EXPORT_IMAGE@('plot.jpg')
  export_cb = 2
end function export_cb

Still learning about Clearwin.

8 Jan 2024 7:42 #30946

Add

  call winop@('%pl[x_min=0,x_max=100]')

immediately before

iw = winio@('%pl&',1400,800,k,dble(vec),dble(real_part),dble(imaginary_part))
10 Jan 2024 7:25 #30949

Thanks Kenneth! That worked fine.

Lester

Please login to reply.