Wednesday 15 May 2013

python - Make a square contour plot in matplotlib -


I can not find matplotlib to create contour plot with equal x and y axes. Note that I try to define figures with equal figs (10,10) and also try to 'equalize' in the axis function. Neither work, as shown by the "circle" which is oval, is:

  import matplotlib.pyplot as import from matplotlib.colors Import from border range from martplatelib . MaxNLocator imports from ticker imports 2 2D grid for numpy np # generation X; Y = borders = 0, 1 + 0.1, 0.1), slice (0, 1 + 0.1, 0.1)] z = y + xz = z [: - 1,: -1] level = MaxNLocator (nbins = 15) .tick_values (Z.min (), z.max ()) # Select the desired look, sensible level, and define a generalization. # Examples which takes the data value and translate those levels into Plt.figure (num = none , Fig = (10,10)) = Separator = plt.get_cmap ('nip-spectral')) Value = range (minimum level, encoder = semipamp, clip = true) # shapes * point * based plot, then its bound point Centers in the environment So do plt.contour (x [: - 1,: -1] + 0.1 / 2., y [: - 1,: -1] + 0.1 / 2., z, level = level, cmap = cmap, zorder = 1) plt.colorbar () plt.axis ([0, 1, 0, 1], 'equal') plt.tight_layout () circle = plt.Circle ((0.4,0.5), 1, color = 'k', Fill = false) plt.gca (). Add_artist (Circle) plt.savefig ('not_square')  


No comments:

Post a Comment