# import pandas as pd # import numpy as np # import matplotlib.pyplot as plt # import seaborn as sns # import urllib.request as urllib2 # import json # def findPairs(): # ids = ['rb1903', 'rb1904', 'rb1905', 'rb1906', 'rb1907', 'rb1908'] # url_5m = 'http://stock2.finance.sina.com.cn/futures/api/json.php/IndexService.getInnerFuturesMiniKLine5m?symbol=' # result = [] # for id in ids: # url = url_5m + id # # print(url) # req = urllib2.Request(url) # rsp = urllib2.urlopen(req) # res = rsp.read() # res_json = json.loads(res) # result.append(res_json) # close_result = [] # for instrument in result: # oneDay_list = [] # for oneDay in instrument: # oneDay_list.append(float(oneDay[-2])) # close_result.append(np.array(oneDay_list)) # close_result = np.array(close_result) # close_result = close_result.T # df = pd.DataFrame(data=close_result, columns=ids) # df.plot() # plt.show() # if __name__ == "__main__": # findPairs() from IPython.display import display import matplotlib.pyplot as plt # 您的绘图代码 plt.plot([1, 2, 3, 4], [1, 4, 9, 16]) plt.title("Sample Plot") # 强制显示图形 display(plt.gcf())