赞
踩
plt.figure(dpi= 150)
plt.figure(figsize=(16,4))
ax = plt.subplot()
ax.contourf(grid_x_plot, grid_y_plot, f_plot, levels = levels, cmap=cmap2)
ax.set_xticks([])
ax.set_yticks([])
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)
plt.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
plt.margins(0, 0)
import matplotlib.colors as col
color1 = '#CEFFCE'
color2 = '#C7E9C0'
color3 = '#74C476'
color4 = '#238B45'
color5 = '#00441B'
cmap2 = col.LinearSegmentedColormap.from_list('own2', [color1, color2, color3, color4, color5])
ax.contourf(grid_x_plot, grid_y_plot, f_plot, levels = levels, cmap=cmap2)
fig = plt.figure(figsize=(x_long,y_long)) ax = plt.subplot() ax.contourf(grid_x_plot, grid_y_plot, f_plot, levels=levels, colors = Colors) ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False) ax.spines['bottom'].set_visible(False) ax.spines['left'].set_visible(False) ax.set_xticks([]) ax.set_yticks([]) plt.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0) plt.margins(0, 0) # 输出为二进制流 canvas = fig.canvas buffer = io.BytesIO() # 获取输入输出流对象 canvas.print_png(buffer) # 将画布上的内容打印到输入输出流对象 data = buffer.getvalue() # 获取流的值 buffer.close() plt.close()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。