3

I am new to geopandas and am trying to plot a map with a legend in regular notation not scientific notation. I understand I must use the legend_kwds and know about the 'fmt' keyword but I've tried multiple settings to no avail. Here is my current code drawing up the map:

img = geodf.plot(figsize=(16, 16), column='rate', cmap='Reds', legend=True,
                       legend_kwds={'label': "Rate",
                                    'orientation': "horizontal",
                                   'pad': 0.01,
                                   'fmt': '%f'})

enter image description here

How do I suppress scientific notation of the legend?

EDIT: I have tried

img.ticklabel_format(useOffset=False)

This does not solve my issue. The legend is still showing values in 1e6. This is because img refers to the main axes of the plot, not the legend's axes. So that, the mentioned answer is definitely not working for this question.

SOLUTION: @swatchai has provided the solution I was looking for. The legend_kwds to use is 'format':"%.0f", not 'fmt'.

rmd_po
  • 381
  • 1
  • 4
  • 12
  • 2
    In `legend_kwds`, you should use `'format':"%.0f"`, (`fmt` is not recognized). – swatchai Dec 06 '20 at 02:16
  • 1
    Someone claims that this question already has an answer. Such answer works on the main axes of the plot, not the legend's axes in this question. – swatchai Dec 06 '20 at 02:27
  • @swatchai SOLVED! Thank you so much, this was the answer I needed! – rmd_po Dec 06 '20 at 21:10
  • If it is solved, you should answer your own question, and mark it as accepted answer. Make a bold/clear comment that this is not the other already answered somewhere else.I will vote up your answer. – swatchai Dec 07 '20 at 01:33
  • Unfortunately I cannot mark my question as solved because someone claimed it already had an answer. I will make an edit in the original question in bold – rmd_po Dec 07 '20 at 15:03
  • img.ticklabel_format(useOffset=False, style='plain') WORKED! – Alex C. Mar 22 '22 at 14:39

1 Answers1

0

I guess you need to format x-axis :

img.ticklabel_format(useOffset=False)
img.show()
Hamza
  • 5,373
  • 3
  • 28
  • 43