@@ -302,11 +302,11 @@ end subroutine add_plot
302
302
! *****************************************************************************************
303
303
304
304
! *****************************************************************************************
305
- ! > author: Jacob Williams
305
+ ! > author: Jimmy Leta
306
306
!
307
307
! Add a histogram plot.
308
308
309
- subroutine add_hist (me , x , label , xlim , ylim , xscale , yscale )
309
+ subroutine add_hist (me , x , label , xlim , ylim , xscale , yscale , bins , normed , cumulative )
310
310
311
311
class(pyplot), intent (inout ) :: me ! ! pyplot handler
312
312
real (wp), dimension (:), intent (in ) :: x ! ! x values
@@ -315,11 +315,18 @@ subroutine add_hist(me, x, label, xlim, ylim, xscale, yscale)
315
315
real (wp),dimension (2 ), intent (in ), optional :: ylim ! ! y-axis range
316
316
character (len=* ), intent (in ), optional :: xscale ! ! example: 'linear' (default), 'log'
317
317
character (len=* ), intent (in ), optional :: yscale ! ! example: 'linear' (default), 'log'
318
+ integer , intent (in ), optional :: bins ! !
319
+ logical , intent (in ), optional :: normed
320
+ logical , intent (in ), optional :: cumulative
318
321
319
322
character (len= :), allocatable :: xstr ! ! x values stringified
320
323
character (len= :), allocatable :: xlimstr ! ! xlim values stringified
321
324
character (len= :), allocatable :: ylimstr ! ! ylim values stringified
325
+ character (len= max_int_len) :: binsstr ! !
322
326
character (len=* ), parameter :: xname = ' x' ! ! x variable name for script
327
+ character (len= :), allocatable :: extras ! ! optional stuff
328
+ character (len= 5 ) :: normedstr= ' '
329
+ character (len= 5 ) :: cumulativestr= ' '
323
330
324
331
if (allocated (me% str)) then
325
332
@@ -334,10 +341,38 @@ subroutine add_hist(me, x, label, xlim, ylim, xscale, yscale)
334
341
call me% add_str(trim (xname)// ' = ' // xstr)
335
342
call me% add_str(' ' )
336
343
344
+ ! get optional inputs (if not present, set default value):
345
+ call optional_int_to_string(bins, binsstr, ' 10' )
346
+
347
+ ! optional arguments:
348
+ if (present (bins)) extras = extras// ' ,' // ' bins="' // binsstr// ' "'
349
+
350
+ if (present (normed) .and. normed) then
351
+ normedstr = ' True'
352
+ else
353
+ normedstr = ' False'
354
+ end if
355
+
356
+ if (present (cumulative) .and. cumulative) then
357
+ cumulativestr = ' True'
358
+ else
359
+ cumulativestr = ' False'
360
+ end if
361
+
337
362
! write the plot statement:
338
363
call me% add_str(' ax.hist(' // &
339
364
trim (xname)// ' ,' // &
340
- ' label="' // trim (label)// ' ")' )
365
+ ' label="' // trim (label)// ' ",' // &
366
+ ' bins=' // trim (binsstr)// ' ,' // &
367
+ ' cumulative=' // trim (cumulativestr)// ' ,' // &
368
+ ' normed=' // trim (normedstr)// ' )' )
369
+
370
+ ! write the plot statement:
371
+ ! call me%add_str('CS = ax.'//contourfunc//'('//xname_//','//yname_//','//zname_//','//&
372
+ ! 'label="'//trim(label)//'",'//&
373
+ ! 'linestyles="'//trim(adjustl(linestyle))//'"'//&
374
+ ! extras//')')
375
+
341
376
342
377
! axis limits:
343
378
if (allocated (xlimstr)) call me% add_str(' ax.set_xlim(' // xlimstr// ' )' )
0 commit comments