matplotlib图显示误导y轴,尽管设置set_ylimit

时间:2015-01-29 00:52:56

标签: python-2.7 matplotlib

我有2个数据点,如下图所示,在绘制它们时我看到了一个已经存在的y轴1,尽管明确强制执行set_yaxis - 我做错了什么?

xs =
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199]
 ys=
[10828623, 5274952, 1085078, 901346, 605910, 569867, 531991, 514140, 466894, 460954, 439024, 379639, 378027, 354425, 302439, 300041, 285898, 268924, 255451, 251349, 244723, 239494, 236684, 231563, 227331, 225260, 215933, 185900, 183423, 183165, 181345, 171513, 168599, 161532, 155134, 152262, 149294, 145263, 144888, 142472, 139841, 137502, 136515, 127380, 126405, 123018, 121811, 116477, 116447, 111383, 106975, 104696, 93530, 92810, 91116, 89956, 88917, 88487, 87681, 86163, 80010, 75076, 74987, 70867, 70330, 69812, 69017, 68317, 67876, 64657, 63097, 62950, 61399, 59045, 58973, 56203, 55505, 54397, 53311, 52447, 50366, 49832, 48918, 47895, 47157, 46534, 45062, 44127, 43042, 42016, 41045, 39971, 39723, 39090, 36163, 35637, 34947, 33352, 31036, 30218, 29766, 29238, 28952, 25899, 25799, 25770, 25159, 24403, 23485, 22593, 22219, 21363, 21207, 20822, 20682, 19827, 19725, 19293, 18411, 17757, 17169, 17046, 16569, 16408, 16248, 16073, 16030, 15775, 14065, 13921, 13529, 13136, 12633, 12213, 12092, 11659, 10983, 10871, 10712, 10679, 10110, 9981, 9687, 9494, 8597, 8241, 8042, 7948, 7896, 7602, 7543, 6734, 6529, 6372, 6095, 6038, 5708, 5679, 5234, 5175, 4941, 4936, 4806, 4222, 4153, 4102, 4079, 3767, 3673, 3538, 3483, 3408, 3350, 3305, 3253, 3121, 3105, 3061, 2894, 2642, 2604, 2600, 2585, 2306, 2294, 2199, 2140, 2035, 1916, 1639, 1619, 1598, 1469, 1393, 1276, 1219, 1160, 1132, 1068, 1010]

enter image description here

# A stripped down code.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df1=pd.read_csv(path,sep=',',header='infer')
xs=df1["col1"] # see values above
ys=df1["col1"] # ys was orignally float , and I converted it to int. 
ax1.set_ylim(min(ys),max(ys))
#(1010, 10828623)
plt.plot(xs,ys)

ax1.set_ylim(min(ys),max(ys))
#(1010, 10828623)

这是因为有一个点是1000万+ - 是否有办法保持这一点并在情节中代表这一点? 另外,考虑到范围如此分散,我预计它不会显示0.4等,而是实际数字,即使是科学记数法。

plt.show()

0 个答案:

没有答案