这里是折线图的代码。它和膳绫擎的散点图很类似,只是在一些变量上有小的变更。
- def lineplot(x_data, y_data, x_label="", y_label="", title=""):
- # Create the plot object
- _, ax = plt.subplots() # Plot the best fit line, set the linewidth (lw), color and
- # transparency (alpha) of the line
- ax.plot(x_data, y_data, lw = 2, color = '#539caf', alpha = 1) # Label the axes and provide a title
- ax.set_title(title)
- ax.set_xlabel(x_label)
- ax.set_ylabel(y_label)
- # Overlay 2 histograms to compare themdef overlaid_histogram(data1, data2, n_bins = 0, data1_name="", data1_color="#539caf", data2_name="", data2_color="#7663b0", x_label="", y_label="", title=""):
- # Set the bounds for the bins so that the two distributions are fairly compared
- max_nbins = 10
- data_range = [min(min(data1), min(data2)), max(max(data1), max(data2))]
- binwidth = (data_range[1] - data_range[0]) / max_nbins if n_bins == 0
- bins = np.arange(data_range[0], data_range[1] + binwidth, binwidth) else:
- bins = n_bins # Create the plot
- _, ax = plt.subplots()
- ax.hist(data1, bins = bins, color = data1_color, alpha = 1, label = data1_name)
- ax.hist(data2, bins = bins, color = data2_color, alpha = 0.75, label = data2_name)
推荐阅读
HTTPS那些协议:TLS, SSL, SNI, ALPN, NPN
沙龙晃荡 | 3月31日 京东、微博、华为拭魅战专家与你合营商量容器技巧实践! 本文存眷个中 Web 办事(HTTPS)相干>>>详细阅读
地址:http://www.17bianji.com/lsqh/40891.html
1/2 1