@@ -437,7 +437,8 @@ end subroutine add_hist
437
437
!
438
438
! @note This requires `use_numpy` to be True.
439
439
440
- subroutine add_contour (me , x , y , z , label , linestyle , linewidth , levels , color , filled , cmap , istat )
440
+ subroutine add_contour (me , x , y , z , label , linestyle , linewidth , levels , color , &
441
+ filled , cmap , colorbar , istat )
441
442
442
443
class(pyplot), intent (inout ) :: me ! ! pyplot handler
443
444
real (wp),dimension (:), intent (in ) :: x ! ! x values
@@ -450,6 +451,7 @@ subroutine add_contour(me, x, y, z, label, linestyle, linewidth, levels, color,
450
451
character (len=* ), intent (in ), optional :: color ! ! color of the contour line
451
452
logical , intent (in ), optional :: filled ! ! use filled control (default=False)
452
453
character (len=* ), intent (in ), optional :: cmap ! ! colormap if filled=True (examples: 'jet', 'bone')
454
+ logical , intent (in ), optional :: colorbar ! ! add a colorbar (default=False)
453
455
integer , intent (out ) :: istat ! ! status output (0 means no problems)
454
456
455
457
character (len= :), allocatable :: xstr ! ! x values stringified
@@ -486,8 +488,8 @@ subroutine add_contour(me, x, y, z, label, linestyle, linewidth, levels, color,
486
488
call me% add_str(' ' )
487
489
488
490
! convert inputs for contour plotting:
489
- call me% add_str(yname_ // ' , ' // xname_ // ' = np.meshgrid(' // trim (xname)// ' , ' // trim (yname)// ' )' )
490
- call me% add_str(zname_// ' = ' // zname)
491
+ call me% add_str(xname_ // ' , ' // yname_ // ' = np.meshgrid(' // trim (xname)// ' , ' // trim (yname)// ' )' )
492
+ call me% add_str(zname_// ' = np.transpose( ' // zname// ' ) ' )
491
493
492
494
! optional arguments:
493
495
extras = ' '
@@ -508,6 +510,10 @@ subroutine add_contour(me, x, y, z, label, linestyle, linewidth, levels, color,
508
510
' linestyles="' // trim (adjustl (linestyle))// ' "' // &
509
511
extras// ' )' )
510
512
513
+ if (present (colorbar)) then
514
+ if (colorbar) call me% add_str(' fig.colorbar(CS)' )
515
+ end if
516
+
511
517
call me% add_str(' ax.clabel(CS, fontsize=9, inline=1)' )
512
518
call me% add_str(' ' )
513
519
0 commit comments