我想用pandas
制作一个对数日志图import numpy as np
import pandas as pd
x = 10**arange(1, 10)
y = 10** arange(1,10)*2
df1 = pd.DataFrame( data=y, index=x )
df2 = pd.DataFrame(data = {'x': x, 'y': y})
df1.plot(logy=True, logx=True)
如何使x轴对数?
答案 0 :(得分:8)
尝试使用pandas
plot功能创建对数日志图时,您必须在关键字参数中选择loglog=True
而不是logx=True, logy=True
。
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
x = 10 ** np.arange(1, 10)
y = 10 ** np.arange(1, 10) * 2
df1 = pd.DataFrame(data=y, index=x)
df1.plot(loglog=True, legend=False)
plt.show()