This is another legacy of imshow also being used for image display. Finally, the origin keyword specifies where (0,0) is placed.Setting it to equal forces equal spacing on the two axes. The aspect ratio can be set in the imshow command itself, as opposed to through modifying the axes.If you don't specify the extent keyword, xmin and ymin are taken to be 0, and xmax and ymax to the number of elements in the data in the x and y directions. The mechanism for specifying the minimum and maximum is the extent keyword, which you set equal to a tuple of 4 numbers (xmin, xmax, ymin, ymax).Thus you don't need to specify every x and y point, just the minimum and maximum. Second, for contour, you are allowed to have x and y points that aren't evenly spaced, whereas for imshow() you aren't. First, imshow is often used as a way of displaying images, in which case there aren't really x and y coordinates, just pixels values. For imshow, you don't give arrays of x and y values.Finally, note that, though we've used it in 2D, the meshgrid command will work for an arbitrary number of dimensions. The keyword indexing='ij' specifies that the x coordinate goes with the first dimension of the output arrays, and the y coordinate with the second. , and similarly yy = y, yy = y, yy = y, and so forth. ![]() ![]() The meshgrid function gives us back a pair of two-dimensional arrays, xx and yy, that represent the x and y coordinates of these mesh points. We can think of these two arrays as defining a 2D grid of points, with formed by combining all the possible x values with all the possible y values. In this case we've passed it two one-dimensional arrays, representing x and y coordinates. The meshgrid function does something very useful. The third line invokes a function you probably haven't seen before, called meshgrid, which is part of the numpy library. The first two lines should look familiar: they just create two arrays, x and y, that go from -2 pi to 2 pi with a spacing of 0.01.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |