Hello, I wanted to ask you for help. I prepare a test program to plot in log scale. I also prepare such plot in Matlab, where on the left side I put label in more detail than in PLplot test program. Is there any possibility to make such plot in PLplot as in Matlab, i.e. making more labels on axis Y in log plot?
Have look on file "plplot_test.pdf" and "matlab_test.pdf" and my source code. For any suggestions or corrections in my program I will be grateful. I do it in PLplot 5.12.0 and gfortran from gcc-6.3.0. Thank you in advance. Andrzej
test_matlab.pdf
Description: Adobe PDF document
test_plplot.pdf
Description: Adobe PDF document
Makefile
Description: Binary data
program plplot_test use plplot use plplot_double implicit none integer, parameter :: dp = kind(1d0) character(len=3), parameter :: infnan(2) = ['Inf','Nan'] integer, parameter :: time = 50 real(dp), dimension(time) :: rms real(dp) :: nan, inf read(infnan,*) inf, nan rms = [ & 3.1253D-1, 2.3104D-1, 1.7497D-1, 1.3670D-1, 1.1087D-1, & 9.3651D-2, 8.2302D-2, 7.4875D-2, 7.0025D-2, 6.6849D-2, & 6.4758D-2, 6.3372D-2, 6.2447D-2, 6.1827D-2, 6.1409D-2, & 6.1127D-2, 6.0936D-2, 6.0807D-2, 6.0720D-2, 6.0660D-2, & 6.0620D-2, 6.0593D-2, 6.0575D-2, 6.0562D-2, 6.0554D-2, & 6.0548D-2, 6.0544D-2, 6.0542D-2, 6.0540D-2, 6.0539D-2, & 6.0538D-2, 6.0538D-2, 6.0537D-2, 6.0537D-2, 6.0537D-2, & 6.0537D-2, 6.0537D-2, 6.0537D-2, 6.0537D-2, 6.0537D-2, & 6.0537D-2, 6.0537D-2, 6.0537D-2, 6.0537D-2, 6.0537D-2, & 6.0537D-2, 6.0537D-2, 6.0537D-2, 6.0537D-2, 6.0537D-2 & ] call plplot_init('test_plplot.pdf',1,1) call loglog(linspace([1, time], time), rms) call plplot_finish() contains !================================================= subroutine plplot_init(filename, nx, ny) implicit none character(len=*), intent(in) :: filename integer, intent(in) :: nx, ny character(len=*), parameter :: device = "pdfcairo" call plsfnam(filename) call plsdev(device); call plssub(ny, nx) call plscolbga(255,255,255,0.3_plflt) call plspage (0.0_dp, 0.0_dp, 1080, 810, 0, 0); call plinit() call plfont(1) end subroutine !================================================= subroutine plplot_finish() implicit none call plend() end subroutine !================================================= subroutine loglog(x,y,color) implicit none real(dp), dimension(:), intent(in) :: x, y integer, optional :: color real(dp), dimension(size(x)) :: xlog, ylog integer :: i,n, warn integer :: finall_color real(dp) :: mm(4) ! (mm) - values of min and max finall_color = 9 if (present(color)) finall_color = color warn = 0 xlog = x ylog = y n = size(x) call calc_min_max(xlog, ylog, mm) if (any(mm <= -inf) .or. any(mm >= inf) .or. any(x <= 0.0) .or. any(y <= 0.0)) then do i=1,n if (xlog(i) <= 0) xlog(i) = NaN if (ylog(i) <= 0) ylog(i) = NaN end do call calc_min_max(xlog, ylog, mm) ! negative values or zero set to its minimum x and y do i=1,n if (isnan(xlog(i))) xlog(i) = 10**mm(1) if (isnan(ylog(i))) ylog(i) = 10**mm(3) end do print('(/,"*** [loglog]: Changed values 0 or negative and these are not plotted ***",/)') warn = 1 end if call plscolbga(255,255,255,0.3_plflt) call pladv(0) call plvpor(0.135_plflt, 0.97_plflt, 0.13_plflt, 0.88_plflt) ! if 10^40 then making plot is to long in time if (all(abs(mm) < 40)) then call plwind(mm(1), mm(2), mm(3), mm(4)) call plscol0(0, 0, 0, 0) call set_log_grid() call set_log_axes() call plcol0(finall_color) call plwidth(2.0_plflt) call plline(log10(xlog), log10(ylog)) if (warn == 1) then call plcol0(1) call plstring([sum(mm(1:2))/2.0], [mm(4)*0.95], "Negative/zero values set to minimum value!") end if else call plcol0(1) call plwind(0.0_dp, 1.0_dp, 0.0_dp, 1.0_dp) call plstring([0.5_dp], [0.5_dp], "Infinity values, so no plot is made!!!") end if end subroutine !================================================= subroutine calc_min_max(x, y, xy_MinMax) implicit none real(dp), intent(in), dimension(:) :: x, y real(dp), intent(out), dimension(4) :: xy_MinMax xy_MinMax = [ minval(x), maxval(x), minval(y), maxval(y) ] xy_MinMax = log10(xy_MinMax) where (is_neginf(xy_MinMax)) xy_MinMax = -16.0_dp where (is_posinf(xy_MinMax)) xy_MinMax = +16.0_dp end subroutine !================================================= subroutine set_log_grid() implicit none integer, parameter :: gray = 240 integer :: r, g, b call plwidth(0.7_plflt) call plstyl( [1500], [1500] ) call plgcol0(6, r, g, b) call plscol0(6, gray, gray, gray) call plcol0(6) call plbox('lgh', 0.0_plflt, 0, 'lgh', 0.0_plflt, 0) call plscol0(6, r, g, b) call plstyl( [integer ::], [integer ::] ) call plwidth(1.0_plflt) end subroutine !================================================= subroutine set_log_axes() implicit none call plwidth(0.7_plflt) call plcol0(0) call plstyl( [integer ::], [integer ::] ) call plbox("lbcnst", 0.0_plflt, 0, "lbcnstv", 0.0_plflt, 0) call plwidth(1.0_plflt) end subroutine !================================================= function linspace(z,n) result(x) implicit none integer, dimension(2), intent(in) :: z integer, intent(in) :: n real(dp) :: x(n), inc_x integer :: i inc_x = (z(2) - z(1)) / (n-1) x = [ (z(1) + i * inc_x, i=0,n-1)] end function !================================================= elemental pure function is_neginf(x) result (r) implicit none logical :: r real(dp), intent(in) :: x r = (x < -huge(x)) end function !================================================= elemental pure function is_posinf(x) result (r) implicit none logical :: r real(dp), intent(in) :: x r = (x > huge(x)) end function !================================================= end program
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Plplot-general mailing list Plplot-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-general