Pygmt.surface - issue with region

how to use pygmt.surfece inside of python function. When I use inside of the function it gives error. When I use directly without using the function it works. Many thanks for your help.

import pygmt
import pandas as pd
import math
def plot_pygmt_map(csv_output_filename):
    counter_data_value = counter_data[['longitude', 'latitude','value']].copy()
    a= math.log10(max_value/100)
    max_value= math.ceil(10**(a))*100
    region = [min_lon,max_lon,min_lat,max_lat]
    print(region, type(min_lon))
    grid_value = pygmt.surface(data=counter_data_value, spacing="0.01", region=region,convergence="0.1", outgrid="counter_data_value.grd")
    #pygmt.surface(data=counter_data_value, spacing="0.01", region=region,convergence="0.1", outgrid="counter_data_value.grd") # I tried also this too

it gives error as follows :

[34.9399, 39.7399, 35.5887, 39.1887] 200 <class 'float'>
surface [ERROR]: Could not parse 34.9399 into Geographical, Cartesian, or Temporal coordinates!
surface [ERROR]: Option -R parsing failure. Correct syntax:

Specify the min/max coordinates of your data region in user units. Use dd:mm[:ss] for regions given in arc degrees, minutes [and seconds]. Use -R<xmin>/<xmax>/<ymin>/⏎
     …<ymax>[+u<unit>] for regions given in projected coordinates, with <unit> selected from e|f|k|M|n|u [Default: e]. If +u is set, projected regions centered on (0,0) may be
     set via -R<halfwidth>[/<halfheight>]+u<unit>, where <halfheight> defaults to <halfwidth> if not given. Use [yyyy[-mm[-dd]]]T[hh[:mm[:ss[.xxx]]]] format for time axes.
     Append +r if -R specifies the coordinates of the lower left and upper right corners of a rectangular area.
Use -Re and -Ra to set exact or approximate regions based on your input data (if applicable). Use -R<gridfile> to use its limits (and increments if applicable). Use -Rg
     and -Rd as shorthand for -R0/360/-90/90 and -R-180/180/-90/90. Derive region from closed polygons from the Digital Chart of the World (DCW): Append a comma-separated list
     of ISO 3166 codes for countries to set region, i.e., <code1>,<code2>,... etc., using the 2-character ISO country codes (see pscoast -E+l for list). To select a state of a
     country (if available), append .state, e.g, US.TX for Texas. To select a whole continent, give the full name as <code> (e.g, -RAfrica). To select a DCW collection, give
     collection tag as <code> (see pscoast -E+n for list). Use +r to modify the region from polygon(s): Append <inc>, <xinc>/<yinc>, or <winc>/<einc>/<sinc>/<ninc> to round
     region to these multiples; use +R to extend region by those increments instead, or use +e which is like +r but makes sure the region extends at least by 0,25 x <inc>.
Alternatively, use -R<code><x0>/<y0>/<n_columns>/<n_rows> for origin and grid dimensions, where <code> is a 2-char combo from [T|M|B][L|C|R] (top/middle/bottom/left/⏎
     …center/right) and grid spacing must be specified via -I<dx>[/<dy>] (also see -r).
surface [ERROR]: Offending option -R34.9399/39.7399/35.5887/39.1887
Traceback (most recent call last):
  File "/home/murat/MEGA/line_to_point_distance/", line 801, in calculate_method1
  File "/home/murat/MEGA/line_to_point_distance/", line 514, in plot_pygmt_map
    grid_pgv = pygmt.surface(data=counter_data_pgv, spacing="0.01", region=region,convergence="0.1", outgrid="counter_data_pgv.grd")
  File "/home/murat/anaconda3/envs/pygmt/lib/python3.12/site-packages/pygmt/helpers/", line 609, in new_module
    return module_func(*args, **kwargs)
  File "/home/murat/anaconda3/envs/pygmt/lib/python3.12/site-packages/pygmt/helpers/", line 773, in new_module
    return module_func(*bound.args, **bound.kwargs)
  File "/home/murat/anaconda3/envs/pygmt/lib/python3.12/site-packages/pygmt/src/", line 161, in surface
  File "/home/murat/anaconda3/envs/pygmt/lib/python3.12/site-packages/pygmt/clib/", line 659, in call_module
    raise GMTCLibError(
pygmt.exceptions.GMTCLibError: Module 'surface' failed with status code 72:
surface [ERROR]: Could not parse 34.9399 into Geographical, Cartesian, or Temporal coordinates!
surface [ERROR]: Option -R parsing failure. Correct syntax:
surface [ERROR]: Offending option -R34.9399/39.7399/35.5887/39.1887
Aborted (core dumped)