Skip to content

Instantly share code, notes, and snippets.

@risyomei
Created June 13, 2019 13:14
Show Gist options
  • Save risyomei/b641f01ba217770dd66659b49fcaac9f to your computer and use it in GitHub Desktop.
Save risyomei/b641f01ba217770dd66659b49fcaac9f to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
from pylab import rcParams
input = [
16.7952,16.7697,16.7076,16.7884,16.7884,16.8884,16.8811,16.6042,16.5514,16.3016,16.2257,16.2257,16.3053,16.3841,16.2822,16.2322,16.2859,16.2952,16.2952,16.1036,16.0794,16.1378,15.8408,15.8193,15.8541,15.8541,15.876,15.8632,15.9046,16.0742,15.459,15.6387,15.6387,15.2758,15.4072,15.4489,15.442,15.419,15.382,15.382,15.38,15.281,14.972,15.079,14.979,14.997,14.997,15.295,15.517,15.606,15.785,15.81,15.747,15.747,15.74,15.852,15.901,15.876,15.883,15.851,15.851,15.873,15.614,15.824,15.715,15.521,15.352,15.352,15.387,15.261,15.221,15.21,15.233,15.281,15.281,15.351,15.313,15.222,15.236,15.313,15.248,15.248,15.196,15.033,15.149,15.11,15.047,15.045,15.045,15.072,15.037,15.031,15.064,15.018,15.244,15.244,15.29,15.304,15.458,15.511,15.439,15.546,15.546,15.45,15.451,15.213,15.237,15.377,15.384,15.384,15.226,15.282,15.38,15.29,15.238,15.309,15.309,15.226,15.244,15.087,15.061,15.1,15.129,15.129,15.04,15.025,15.062,15.193,15.16,15.171,15.171,15.17,15.35,15.363,15.539,15.537,15.406,15.406,15.386,15.423,15.443,15.402,15.484,15.476,15.476,15.434,15.414,15.329,15.359,15.312,15.32,15.32,15.327,15.403,15.363,15.422,15.513,15.431,15.431,15.48,15.467,15.282,15.233,15.212,15.246,15.246,15.368,15.42,15.22,15.697,15.597,15.64,15.64,15.717,15.758,15.918,15.845,15.965,16.076,16.076,16.029,16.064,16.065,16.311,16.292,16.356,16.356,16.254,16.345,16.45,16.573,16.524,16.469,16.469,16.595,16.536,16.533,16.469,16.648,16.673,16.673,16.718,16.682,16.629,16.995,16.952,16.92,16.92,16.854,16.966,16.85,16.911,16.873,16.874,16.874,16.821,16.902,16.904,16.74,16.825,16.822,16.822,16.886,16.976,16.944,16.896,16.769,16.884,16.884,16.797,16.717,16.743,16.521,16.595,16.57,16.57,16.52,16.503,16.541,16.689,16.723,16.652,16.652,16.552,16.51,16.431,16.595,16.709,16.718,16.718,16.661,16.448,16.446,16.383,16.448,16.376,16.376,16.36,16.296,16.301,16.355,16.476,16.437,16.437,16.51,16.503,16.631,16.532,16.402,16.418,16.418,16.419,16.492,16.423,16.39,16.323,16.311,16.311,16.324,16.309,16.519,16.586,16.573,16.51,16.51,16.479,16.489,16.481,16.58,16.676,16.606,16.606,16.571,16.583,16.558,16.396,16.369,16.31,16.31,16.31,16.333,16.148,16.088,16.103,16.16,16.16,16.001,16.003,16.079,16.116,16.225,16.158,16.158,16.141,16.014,16.102,16.062,16.035,16.079,16.079,16.114,15.993,15.88,15.829,15.788,15.754,15.754,15.734,15.781,15.803,15.813,15.819,15.823,15.823,15.991,16.047,16.139,16.137,16.138,16.146,16.146,16.213,16.26,16.25,16.337,16.279,16.306,16.306,16.292,16.477,16.476,16.48,16.477,16.407,16.407,16.439,16.473,16.279,16.027,16.12,16.128,16.128,16.132,16.107,16.204,16.256,16.182,16.226,16.226,16.223,16.166,16.255,16.336,16.318,16.19,16.19,16.217,16.072,16.069,16.183,16.221,16.21,16.21,16.139,16.164,16.2,16.181,16.316,16.234,16.234,16.3,16.295,16.323,16.251,16.241,16.257,16.257,16.299,16.407,16.459,16.588,16.489,16.538,16.538,16.589,16.625,16.679,16.637,16.691,16.716,16.716,16.761,16.791,16.704,16.665,16.646,16.581,16.581,16.583,16.582,16.549,16.554,16.457,16.402,16.402,16.395,16.477,16.529,16.491,16.464,16.406,16.406,16.413,16.427,16.466,16.392,16.358,16.429,16.429,16.467,16.436,16.397,16.479,16.358,16.353,16.353,16.403,16.505,16.534,16.481,16.318,16.345,16.345,16.31,16.4,16.352,16.399,16.454,16.444,16.444,16.487,16.428,16.697,16.737,16.775,16.796,16.796,16.772,16.667,16.657,16.76,16.626,16.622,16.622,16.631,16.761,16.828,16.841,16.964,16.887,16.887,16.925,16.91,16.909,17.022,16.995,16.973,16.973,16.934,16.857,16.998,16.887,16.907,16.889,16.889,16.917,16.963,16.878,16.881,16.952,16.906,16.906,17.001,17.074,17.001,17.029,17.017,16.973,16.973,16.949,16.932,17.006,16.961,17.081,17.125,17.125,17.117,17.157,17.167,17.129,17.138,17.071,17.071,17.079,17.072,17.248,16.92,16.75,16.75,16.77,16.9,16.94,16.92,16.86,16.87,16.87,16.91,16.95,17.02,16.82,16.65,16.66,16.66,16.63,16.69,16.73,16.77,16.84,16.87,16.87,16.85,16.94,16.86,16.82,16.8,16.74,16.74,16.72,16.81,16.8223,16.7269,16.5939,16.5962,16.5736,16.7473,16.8107,16.7936,16.9675,16.9145,16.905,16.9047,16.9278,16.8565,16.9283,16.9842,17.0327,16.9679,16.9684,16.97,17.0051,17.0144,17.1068,17.1084,17.057,17.0457,17.063,17.0975,17.1053,17.1056,17.1195,17.1063,17.2111,17.2571,17.2781,17.2453,17.219,17.2669,17.2579,17.1529,17.1672,17.1689,17.1654,17.1094,17.1202,17.2695,17.2302,17.2978,17.2724,17.2886,17.2922,17.2914,17.3693,17.4021,17.362,17.3636,17.3658,17.3849,17.2767,17.1781,17.139,17.1247,17.1244,17.0802,16.955,16.8846,16.9514,16.9674,17.062,17.0618,17.0726,17.1423,17.1762,17.2133,17.0593,17.1126,17.1108,17.1719,17.2076,17.2733,17.1959,17.2132,17.1928,17.1928,17.1602,16.9457,17.0252,16.9874,16.9565,16.9034,16.9034,16.7373,16.7106,16.6394,16.6417,16.6912,16.7221,16.7236,16.6225,16.6802,16.6378,16.6531,16.673,16.6312,16.6338,16.6886,16.7751,16.6545,16.8618,16.7958,16.8035,16.8027,16.8334,16.8212,16.8442,16.7233,16.5923,16.4572,16.4545,16.3526,16.3181,16.4286,16.3435,16.296,16.3021,16.3024,16.2821,16.3168,16.4145,16.3704,16.2482,16.2913,16.2911,16.2781,16.2747,16.2398,16.2859,16.1907,16.1961,16.1961,16.1504,16.077,16.1195,16.1195,16.1195,16.05,16.05,16.122,16.084,16.063,16.137,16.239,16.316,16.316,16.255,16.289,16.2975,16.309,16.181,16.232,16.232,16.252,16.277,16.3,16.308,16.146,16.197,16.197,16.155,16.205,16.207,16.253,16.292,16.292,16.292,16.28,16.272,16.373,16.347,16.448,16.396,16.396,16.405,16.392,16.423,16.365,16.453,16.529,16.529,16.573,16.536,16.55,16.63,16.551,16.532,16.532,16.351,16.315,16.328,16.203,16.247,16.185,16.185,16.176,16.182,16.175,16.19,16.188,16.217,16.217,16.204,16.221,16.205,16.117,16.087,16.084,16.111,16.177,16.209,16.243,16.396,16.406,16.406,16.327,16.335,16.369,16.392,16.414,16.337,16.337,16.37,16.305,16.36,16.325,16.285,16.245,16.245,16.223,16.158,16.244,16.257,16.22,16.233,16.233,16.299,16.326,16.334,16.294,16.322,16.297,16.297,16.462,16.47,16.448,16.459,16.355,16.364,16.364,16.339,16.362,16.451,16.489,16.454,16.387,16.387,16.427,16.304,16.276,16.239,16.12,16.079,16.079,16.055,16.005,16.025,16.123,16.044,16.013,16.013,15.989,15.923,15.876,15.629,15.705,15.774,15.774,15.782,15.848,15.917,15.907,16.038,16.023,16.023,15.94,15.962,16.048,16.129,16.088,16.174,16.174,16.14,16.083,16.122,16.115,16.188,16.219,16.219,16.225,16.187,16.262,16.191,16.137,16.207,16.207,16.271,16.28,16.228,16.259,16.259,16.249,16.249,16.206,16.289,16.342,16.365,16.286,16.294,16.294,16.286,16.321,16.359,16.45,16.444,16.463,16.463,16.513,16.536,16.501,16.57,16.663,16.662,16.662,16.676,16.676,16.662,16.628,16.506,16.502,16.502,16.519,16.567,16.57,16.567,16.616,16.579,16.579,16.579,16.544,16.631,16.518,16.512,16.339,16.339,16.348,16.392,16.433,16.342,16.444,16.486,16.486,16.516,16.545,16.599,16.556,16.606,16.601,16.601,16.558,16.562,16.525,16.516,16.657,16.684,16.684,16.668,16.653,16.726,16.671,16.669,16.67,16.67,16.653,16.627,16.626,16.653,16.524,16.565,16.565,16.562,16.537,16.523,16.555,16.53,16.475,16.475,16.413,16.35,16.255,16.1574,16.123,16.111,16.111,15.942,15.938,15.897,15.9384,15.856,15.909,15.909,15.886,15.918,15.998,15.966,15.8486,15.839,15.839,15.84,15.848,15.818,15.86,15.7686,15.682,15.682,15.664,15.627,15.666,15.649,15.697,15.657,15.657,15.659,15.717,15.6397,15.666];
max_diff = 0.05;
ifplus = True if input[1] - input[0] > 0 else False;
cur= input[0];
x=[];
y=[];
x.append(0)
y.append(input[0])
x.append(0);
i=0;
for point in input:
if ifplus:
if point > cur:
cur = point;
if cur - point >= max_diff:
ifplus = False;
y.append(cur);
i = i + 1;
x.append(4 * i);
y.append(cur);
x.append(4 * i);
cur=point;
else:
if point < cur:
cur = point;
if point - cur >= max_diff:
ifplus = True;
y.append(cur);
i = i + 1;
x.append(4 * i);
y.append(cur);
x.append(4 * i);
cur=point;
y.append(input[-1])
# rcParams['figure.figsize'] = 30, 20
# for xx,yy in zip(x,y):
# label = "{:.05f}".format(yy)
# plt.annotate(label, # this is the text
# (xx,yy), # this is the point to label
# textcoords="offset points", # how to position the text
# xytext=(0,20), # distance from text to points (x,y)
# ha='center') # horizontal alignment can be left, right or center
plt.scatter(x, y, s=1)
plt.plot(x, y)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment