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
Asked
Active
Viewed 86 times
0
-
It's called logarithmic scale. – Péter Leéh May 18 '20 at 15:35
-
[Duplicate Question] Please have a look here: https://stackoverflow.com/questions/773814/plot-logarithmic-axes-with-matplotlib-in-python – Marcel Flygare May 18 '20 at 16:18
1 Answers
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