from matplotlib import pyplot as plt
from matplotlib.path import Path
from matplotlib.patches import PathPatch

import numpy
import geopandas as gpd
from shapely.wkt import loads
import cartagen as c4

line = loads('LineString (-187679.00380423796013929 5374633.56763217970728874, -187645.19423947550239973 5374637.70757888536900282, -187630.70442600589012727 5374642.53751670848578215, -187614.83463030107668601 5374652.1973923547193408, -187598.27484347863355651 5374667.37719694245606661, -187583.09503889142069966 5374693.59685941133648157, -187575.50513659781427123 5374716.36656629201024771, -187568.6052254218084272 5374738.44628205522894859, -187563.08529648100375198 5374759.83600670099258423, -187559.63534089300082996 5374781.22573134675621986, -187553.42542083459557034 5374798.47550928685814142, -187541.69557183535653166 5374813.65531387366354465, -187524.4457938953419216 5374824.69517175480723381, -187507.88600707292789593 5374830.90509181376546621, -187489.25624689768301323 5374831.59508293122053146, -187478.90638013367424719 5374828.83511846046894789, -187462.34659331126022153 5374817.79526057932525873, -187451.99672654725145549 5374801.92546487413346767, -187444.40682425364502706 5374779.15575799345970154, -187439.57688643041183241 5374757.07604223024100065, -187437.5069130776100792 5374735.68631758447736502, -187433.36696637200657278 5374708.08667288068681955, -187430.60700190160423517 5374683.93698376510292292, -187425.77706407840014435 5374657.71732129622250795, -187420.25713513759546913 5374626.66772100422531366, -187409.90726837358670309 5374597.68809406459331512, -187396.79743713917559944 5374579.05833388958126307, -187372.64774802312604152 5374568.01847600750625134, -187349.18805002470617183 5374566.63849377259612083, -187327.79832537905895151 5374577.67835165373980999, -187311.92852967424551025 5374591.4781740065664053, -187300.88867179263615981 5374610.10793418157845736, -187293.98876061663031578 5374630.11767659150063992, -187289.84881391102680936 5374652.1973923547193408, -187285.01887608779361472 5374683.93698376510292292, -187279.49894714698893949 5374707.3966817632317543, -187274.66900932378484868 5374733.61634423211216927, -187268.45908926537958905 5374766.04592675901949406, -187258.10922250137082301 5374791.57559811044484377, -187245.68938238456030376 5374808.82537605054676533, -187226.36963109171483666 5374822.62519840244203806, -187206.35988868129788898 5374829.52510957885533571, -187187.73012850608211011 5374825.38516287319362164, -187177.38026174204424024 5374814.34530499111860991, -187162.89044827243196778 5374795.71554481610655785, -187151.85059039082261734 5374770.87586458213627338, -187144.26068809721618891 5374743.27621987834572792, -187139.43075027401209809 5374712.91661070380359888, -187135.98079468600917608 5374677.72706370614469051, -187134.60081245080800727 5374657.71732129622250795, -187134.60081245080800727 5374630.11767659150063992, -187129.08088350997422822 5374601.13804965279996395, -187122.18097233396838419 5374581.12830724194645882, -187107.69115886435611174 5374568.01847600750625134, -187082.16148751313448884 5374566.63849377259612083, -187058.70178951468551531 5374574.22839606646448374, -187038.00205598666798323 5374588.02821841835975647)')
line = c4.smooth_gaussian(line, sigma=10, sample=10)

fig = plt.figure(1, (12, 8))

sub1 = fig.add_subplot(111)
sub1.set_aspect('equal')
sub1.axes.get_xaxis().set_visible(False)
sub1.axes.get_yaxis().set_visible(False)

coords = list(line.coords)
points = c4.inflexion_points(line)

path1 = Path(numpy.asarray(line.coords)[:, :2])
sub1.add_patch(PathPatch(path1, facecolor="none", edgecolor='gray', linewidth=1))

for i in points:
    p = coords[i]
    sub1.plot(p[0], p[1], linestyle="", marker='o', color="red")

sub1.autoscale_view()
plt.show()