Instead I want the spikes to be at (0,1),(2,1),(3,5). We use Tkinter to create the GUI application in python in this program, we mainly use the Tkinter module, so we first have to import the Tkinter module. So the essence of the problem is how do I calculate the X and Y indices such that they correspond to x1, y1 in real coordinates.įor example, if I simply do Z = 1, contourf gives this: I want Z to have 1's at locations which are specified by the array points. Another way to look at it is I want: Z = 1 There has to be some sort of conversion which I'm not able to figure out. The problem I'm having is that the indices for Z cannot be the same as the coordinates in points. So I could do something like plt.contourf(X,Y,Z). When I mean masses, I just mean a scalar at those points. Now, what I want to do is to create a 2D array 'Z',(a map of the masses)that contains masses at the locations that are in the array points. The first is the starting point, the second is the ending point, and the third argument is the step size. The range() function takes in 3 arguments. Now, say I create a 2D meshgrid using: x = np.linspace(-10,10,10) Arrays in Python are called lists, and we can easily create a list of the numbers 1 to n in our Python code. The first thing we need is a data structure to define our grid (a list of lists or array of arrays works fine). Now, I can plot using : plt.plot(x1,y1,'.') Maps are common as grid references and give you a blueprint for building a grid and the contents of said grid in one data structure (popular in mazes/code interviews, tile games, and computer vision/AI ). It will set up default instances of the other classes and manage them. For simple applications, and to help you get started, wx.grid.Grid is the only class you need to refer to directly. They provide a rich set of features for display, editing, and interacting with a variety of data sources. Points = np.array(,]) # array containing the coordinates of masses(points) in the form np.ed (21) To generate our array, we’ll use the normal method in the NumPy random module. wx.grid.Grid and its related classes are used for displaying and editing tabular data. I can create this using: import numpy as np Suppose I have a coordinate grid with a few points(masses) sprinkled in the grid.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |