Python 以symlog比例绘制散布会使图形变形-PyPlot

Python 以symlog比例绘制散布会使图形变形-PyPlot,python,matplotlib,scatter,Python,Matplotlib,Scatter,我有下一个密码 df2 = pd.read_csv('../../../../datos/comp-algoritmos-con-exacto-variando-m.csv', sep=', ', engine='python') df2.drop(['fronteraExacto'], axis = 1, inplace = True, errors = 'ignore') df2.drop(['fronteraHConstructiva'], axis = 1, inplace = True

我有下一个密码

df2 = pd.read_csv('../../../../datos/comp-algoritmos-con-exacto-variando-m.csv', sep=', ', engine='python')
df2.drop(['fronteraExacto'], axis = 1, inplace = True, errors = 'ignore')
df2.drop(['fronteraHConstructiva'], axis = 1, inplace = True, errors = 'ignore')
df2.drop(['fronteraBLocal'], axis = 1, inplace = True, errors = 'ignore')
df2.drop(['fronteraGrasp'], axis = 1, inplace = True, errors = 'ignore')
print(df2)
dots_size=4
ax1 = df2.plot(kind='scatter', s=dots_size, x='m', y='tiempoExacto', grid=True, label="Frontera Exacto")
ax1 = df2.plot(kind='scatter', s=dots_size, x='m', y='tiempoHConstructiva', color='r', grid=True, label="Frontera H. Constr.", ax = ax1)
ax1 = df2.plot(kind='scatter', s=dots_size, x='m', y='tiempoBLocal', color='g', grid=True, label="Frontera B. Local", ax = ax1)
ax1 = df2.plot(kind='scatter', s=dots_size, x='m', y='tiempoGrasp', color='y', grid=True, label="Frontera Grasp", ax = ax1)
plt.title('Tiempos')
plt.ylabel(r'Tiempo(ns)')
# plt.yscale('symlog') ATENTION TO THIS LINE!!
plt.savefig('../../../../pics/tiempos-comp-algoritmos-con-exacto-variando-m.png')
plt.show()
这给了我这个输出:

 n    m  tiempoExacto  tiempoHConstructiva  tiempoBLocal  tiempoGrasp
0    25    1        289874                 3007          2857       247956
1    25    2        203436                 1794          1964       165354
2    25    3        199646                 1772          1161       159057
3    25    4        223909                 1765           736       157588
4    25    5        214165                 1798          1098       174839
5    25    6        279070                 3445           973       199077
6    25    7        263223                 2350           835       193263
7    25    8        257811                 2558           805       189707
8    25    9        354507                 4653          1144       245325
9    25   10        395984                 4355          1098       288259
10   25   11        291564                 3973           842       219286
11   25   12        288499                 2910           779       232442
12   25   13        402838                 5401          1036       302323
13   25   14        435167                 3935          1185       269851
14   25   15        450570                 6282          1152       333766
15   25   16        412138                 5655          1114       340062
16   25   17        389859                 4966           860       290926
17   25   18        498010                 7013          1311       321857
18   25   19        471293                 6537          1102       338808
19   25   20        433426                 4863          1157       289733
20   25   21        336328                 3550           780       238836
21   25   22        367585                 5766           991       298932
22   25   23        531825                 7747          1141       358397
23   25   24        524009                10696          1156       391149
24   25   25        368215                 7413          1036       289017
25   25   26        360510                 5610           807       318878
26   25   27        546772                 7799          1065       396269
27   25   28        514789                 8387          1038       339396
28   25   29        463196                 7498          1105       426917
29   25   30        529734                 9127          1028       463194
..   ..  ...           ...                  ...           ...          ...
265  25  266     868577063                37591          2283      2246070
266  25  267    1262679484                44528          4632      2253722
267  25  268    1212672940                44571          4807      2407831
268  25  269    1019284263                33038          7493      2287368
269  25  270    1857647918                51692          6937      2656487
270  25  271    1753505372                40772          6134      2279160
271  25  272    2580494938                38455          1730      2234590
272  25  273    1933046874                36684          3925      2189667
273  25  274    2656094578                36451          1586      2232921
274  25  275    3447330447                35626          1780      2251709
275  25  276    3042545045                51319          3443      2719259
276  25  277    3627587870                36521          1546      2217240
277  25  278    3977405727                36362          2425      2228196
278  25  279    4986717985                36940          1728      2293531
279  25  280    3959366565                41242          3167      2255175
280  25  281    5942765531                36878          2170      2257058
281  25  282    6145377070                37564          2149      2216758
282  25  283    7019861622                56191          2893      2305268
283  25  284    8014988961                39753          2514      2272142
284  25  285    8957960650                37519          1635      2269699
285  25  286   11242969887                37037          1658      2284985
286  25  287   16468853842                37608          1619      2269580
287  25  288   18933902993                37949          1617      2519840
288  25  289   19375925006                56165          1824      2342211
289  25  290   18284866409                37777          1610      2282389
290  25  291   26846017659                38446          1631      2300149
291  25  292   30580627155                38236          1599      2317638
292  25  293   49887936812                43837          1786      2442593
293  25  294   48197141425                39523          1639      2395371
294  25  295   62145907370                39573          1636      2298693

[295 rows x 6 columns]

因此,当我尝试将比例更改为
symlog
(取消标记行的注释)时,我得到了以下数字:

如您所见,线条渲染不好(我认为),y值显示不好。你知道为什么会发生这种情况,以及我如何解决它吗


编辑

我尝试用
log
比例绘制它,而不是
symlog
得到下一个结果:


看起来没问题,但其中两个函数消失了。

因为似乎没有任何负值可显示,所以使用对数刻度而不是符号可能是更好的选择

plt.yscale('log')
如果需要直线而不是单个散点,请使用

df2.plot(kind='line', ...)

由于您似乎没有任何负值可显示,因此在这里使用对数刻度而不是符号可能是更好的选择

plt.yscale('log')
如果需要直线而不是单个散点,请使用

df2.plot(kind='line', ...)

在对数刻度中添加新绘图时,可能没有正确更新限制,您可以尝试手动更改它们吗
ax.set_ylim(10**2,10**11)
在对数刻度中添加新绘图时,可能没有正确更新限制,您可以尝试手动更改它们吗<代码>ax.set_ylim(10**2,10**11)