在matplotlib中使用logscale时如何修复怪异的图?

时间:2019-10-15 14:22:16

标签: python plot data-visualization

我想用对数标度的xscale绘制一个简单的双曲线(这里由n = 1的希尔方程给出),但是由于某种原因,我在行中得到了一个奇怪的“扭结”。我不确定是否缺少一些琐碎的东西,或者这是一个错误。有人知道如何解决吗?

以以下代码为例:

x_eval = np.linspace(0, 10, 200) y_eval = hill_model.eval(x=x_eval, n=1, k=1, start=0.75, end = 1) plt.plot(x_eval,y_eval)

https://drive.google.com/open?id=1S80B1M_Nn55NRDvP5TMw1FtNV_-qQvOs

该图看起来很好,但是当我添加plt.xscale('symlog'):

https://drive.google.com/open?id=1LRFGyfKtGdC5G3TKVMB80aZtuj-MP3s9

为什么有什么主意?

(仅供参考,y_eval是下面的数组,如果需要绘制数据的话)

y_eval = [0.75, 0.76196172, 0.77283105, 0.78275109, 0.791841, 0.8002008 , 0.80791506, 0.81505576, 0.82168459, 0.82785467, 0.83361204, 0.83899676, 0.84404389, 0.84878419, 0.85324484, 0.85744986, 0.86142061, 0.86517615, 0.86873351, 0.87210797, 0.87531328, 0.87836186, 0.88126492, 0.88403263, 0.88667426, 0.88919822, 0.8916122 , 0.89392324, 0.89613779, 0.89826176, 0.9003006 , 0.90225933, 0.90414258, 0.90595463, 0.90769944, 0.90938069, 0.91100179, 0.91256591, 0.91407599, 0.9155348 , 0.91694491, 0.9183087 , 0.91962843, 0.9209062 , 0.92214397, 0.92334361, 0.92450683, 0.92563528, 0.92673049, 0.9277939 , 0.9288269 , 0.92983075, 0.93080668, 0.93175583, 0.9326793 , 0.9335781 , 0.93445323, 0.93530559, 0.93613607, 0.9369455 , 0.93773467, 0.93850433, 0.93925519, 0.93998794, 0.94070322, 0.94140165, 0.94208382, 0.94275029, 0.94340159, 0.94403825, 0.94466073, 0.94526953, 0.94586507, 0.94644779, 0.9470181 , 0.9475764 , 0.94812304, 0.94865841, 0.94918284, 0.94969666, 0.9502002 , 0.95069376, 0.95117763, 0.95165209, 0.95211742, 0.95257388, 0.95302172, 0.95346118, 0.95389249, 0.95431589, 0.95473157, 0.95513977, 0.95554066, 0.95593446, 0.95632133, 0.95670148, 0.95707506, 0.95744226, 0.95780322, 0.95815812, 0.95850709, 0.95885029, 0.95918786, 0.95951993, 0.95984665, 0.96016813, 0.96048451, 0.9607959 , 0.96110242, 0.96140419, 0.96170131, 0.96199389, 0.96228203, 0.96256584, 0.96284541, 0.96312083, 0.9633922 , 0.96365961, 0.96392313, 0.96418287, 0.96443888, 0.96469127, 0.9649401 , 0.96518544, 0.96542738, 0.96566598, 0.9659013 , 0.96613342, 0.96636241, 0.96658831, 0.96681121, 0.96703115, 0.96724819, 0.96746239, 0.96767381, 0.9678825 , 0.96808852, 0.96829191, 0.96849272, 0.968691 , 0.9688868 , 0.96908017, 0.96927116, 0.96945979, 0.96964613, 0.9698302 , 0.97001206, 0.97019173, 0.97036927, 0.9705447 , 0.97071807, 0.97088941, 0.97105876, 0.97122614, 0.9713916 , 0.97155517, 0.97171688, 0.97187677, 0.97203485, 0.97219117, 0.97234575, 0.97249862, 0.97264981, 0.97279934, 0.97294725, 0.97309356, 0.9732383 , 0.97338149, 0.97352315, 0.97366331, 0.973802 , 0.97393924, 0.97407504, 0.97420943, 0.97434244, 0.97447409, 0.97460439, 0.97473337, 0.97486104, 0.97498743, 0.97511256, 0.97523644, 0.97535909, 0.97548053, 0.97560078, 0.97571986, 0.97583779, 0.97595457, 0.97607023, 0.97618478, 0.97629824, 0.97641062, 0.97652194, 0.97663222, 0.97674147, 0.9768497 , 0.97695692, 0.97706316, 0.97716843, 0.97727273]

0 个答案:

没有答案