1

I am trying to plot a line in a GeoPandas dataframe via matplotlib. also I am adding a basemap and a polygon. However as seen in the picture below on the right top, the line is plotted with only a width of one pixel is too small. The error only arises, when I plot the image in a loop. When I plot the image only once, there is no error.

i tried:

  • linewidth=
  • setting base and ax to None at the beginning of each loop
  • plt.close('all') at the beginning of each loop

My code:

geojsons=[geojson1,geojson2]
for geojson in geojsons:    
    base = planningarea.plot(color='none', edgecolor='black')
    add_basemap(base, zoom=11, url=ctx.sources.ST_TERRAIN_BACKGROUND)
    geojson.plot(ax=base, color='red')
    plt.show()

enter image description here

the add_basemap function is from here

  • 1
    There is no 'picture below'. What have you tried? Can you provide minimal working example? There is no clear reason why linewidth should not work, we need more information to be able to help. – martinfleis Aug 5 at 15:26
  • thanks for the input. hope, my edits made the question clearer... – Leo Aug 7 at 9:29
  • Did you try linewidht or linewidth? Does it work if you do not add a basemap and polygon? – bugmenot123 Aug 7 at 14:07
  • yeah I used 'linewidth'... typo... leaving out the basemap has no effect on the thickness of the line – Leo Aug 7 at 14:18
  • I am struggling to replicate this behaviour. On that image, the black outline is planningarea? And base = planningarea.plot(color='none', edgecolor='black', linewidth=5) does not make an effect? Where is geojson on this image? Can you try to provide minimal working example to replicate this behaviour? There might be some code before this in your script affecting it. – martinfleis Aug 7 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.