0

enter image description here

I would like to create a similar graph, in this case China and USA have huge PIB that I cant see the details for small countries

Ch3steR
  • 20,090
  • 4
  • 28
  • 58
Julia
  • 15
  • 1

1 Answers1

0

For this, you can use ax.set_xscale:

import matplotlib.pyplot as plt
from matplotlib.ticker import ScalarFormatter

plt.scatter(your_data)
ax = plt.gca() #get current axis object
ax.set_xscale('log') #you can use 'symlog' if your data is close to 0
ax.set_yscale('log')
#if you don't want to show the ticks in scientific notation
for axis in [ax.xaxis, ax.yaxis]:
    formatter = ScalarFormatter()
    formatter.set_scientific(False)
    axis.set_major_formatter(formatter)
olenscki
  • 487
  • 7
  • 22