<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9FUXlWOC5wbmcifQ==” alt =“在此处输入图像描述”>
我想创建一个类似的图,在这种情况下,中国和美国拥有庞大的PIB,我看不到小国的详细信息
为此,您可以使用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)