这里的例子 What is the difference between 'log' and 'symlog'? 很好地显示了原点的线性刻度如何与其他地方的对数刻度一起使用。我想走另一条路。我想有一个从1-100的对数刻度,然后一个线性!从100到1000。我有什么选择?如上图所示 这个尝试不起作用
import matplotlib.pyplot as plt
plt.figure()
plt.errorbar(x, y, yerr=yerrors)
plt.xscale('symlog', linthreshx= (100,1000))
问题似乎是linthreshx被定义为取范围(-x,x)。所以如果x是5,我们可以得到一个线性标度。一个局限于起源。我认为简单地选择一个不同的范围应该是可行的,但事实并非如此。有什么想法吗?
我假设你想要靠近原点的直线,更远的对数,因为“symlog”是相反的,所以我不能得出像这样好的数据,但是你可以把它和轴网格放在一起:
From the response of user1318806 to cphlewis:
你好!如果您想要x轴上的log+线性组合(根据Duncan Watts and CubeJockey的代码模式):
上面的代码产生:
(杂项)这里有一个非常小的标题固定,右边没有记号:
添加这些行将得到:
pythonmatplotlib
这个解决方案对cphlewis's answer进行了添加,这样就有了一个平滑的转换,并且绘图似乎有一致的记号标记。我的零钱加上了这三行:
axLin.spines['bottom'].set_visible(False)
axLin.xaxis.set_ticks_position('top')
plt.setp(axLin.get_xticklabels(), visible=False)
总的来说,代码是
相关问题 更多 >
编程相关推荐