my goal create number of matplotlib plots , arrange them in large array. purpose, need ensure output images of matplotlib plots square. how can done?
here's segment of code:
figure = matplotlib.pyplot.figure() figure.suptitle(label, fontsize = 20) #figure.set_size_inches(19.7, 19.7) matplotlib.pyplot.scatter( variable_1_values, variable_2_values, s = marker_size, c = "#000000", edgecolors = "none", label = label, ) matplotlib.pyplot.xlabel(label_x) matplotlib.pyplot.ylabel(label_y) legend = matplotlib.pyplot.legend( loc = "center left", bbox_to_anchor = (1, 0.5), fontsize = 10 ) print("save {filename}".format(filename = filename)) matplotlib.pyplot.savefig( filename, bbox_extra_artists = (legend,), bbox_inches = "tight", dpi = 700 )
i know how set figure square, need output image set square. conceptually simple taking default output image , extending background necessary make image square.
not sure if looking for, produces 600x600 pixel png image me.
import numpy np import matplotlib.pyplot plt = np.random.normal(size=1000) b = np.random.normal(size=1000) fig = plt.figure(figsize=(6,6)) plt.plot(a,b,'g.') plt.xlabel("x axis label") plt.ylabel("y axis label") plt.title("random numbers in scatter plot") fig.savefig("test.png")
Comments
Post a Comment