So I have this function,
func(a,x,y)
where x,y are the graphs coordinates, and a some other data (it doesnt really matter what a is for this problem)
I want this function to make subplots automatically,
so when the function is called and n number of times
func(a2,x2,y2)
func(a3,x3,y3)
func(a4,x4,y4)
.
.
func(an,xn,yn)
It should show n subplots on a graph
Note it is important that the function works in this way for my usecase, I dont want to be inputting an array of [a1,a2,...],[x1,x2,...],[y1,y2,...] and then plotting them all, I want to call each of the graph function seperately
Related
I have a list of (two dimensional) matrices which I want to combine into an animation. The matrices are integer valued with a specified lower and upper bound (in my case from zero to six). I would now like to build an animation where each of the frames consists of the contents of the matrix.
Now, I have managed to get this working if each frame is merely showing the numeric values via matplotlib's built-in matplotlib.pyplot.matshow. Namely, I defined an update function
def update_frames(frame):
animation_image.set_array(matrices[frame])
return animation_image,
where matrices contains the list of integer valued matrices I want to animate. Then, I could pass this into the animation module via
animation_image = ax.imshow(matrices[0])
ani1 = animation.FuncAnimation(fig, update_frames, frames=len(matrices), blit=True)
to obtain the desired result.
I now, however, want to take this a step further by replacing each square on the grid with a specific image, whereas all the images are resized to be of a fixed square shape. For example, at each frame I want to draw a grid of images where the image for each grid cell depends on the integer in the matrix.
Here is a sample animation that I get when using the code snippet above:
I do not have finalized versions of the pictures I would like to show up in the grid yet, but I was thinking of textures that resemble these:
Optimally, I would then end up with grids looking like this (aside from the different placement of objects on the grid as compared to the animation above).
Any help would be greatly appreciated!
I have a data which I am trying to plot. However when I call plot function, I get a weird line. How can I get rid of this thing and why does it occur ?
The plot function draws lines between points. If there is a "weird" line, then it means you are providing two consecutive points that form that line
I am trying to plot two arrays r_mod and gbp in python after importing matplotlib. Array r_mod contains random numbers. When I plot the two array with the command plt.plot(r_mod,gbp,"o"), I get the first figure below which shows the global behavior of the relevant function stored in array gbp. However, when plotting with plt.plot(r_mod,gbp), I get the second figure below which does not show the global behavior of the function.
Can someone tell me how to fix this problem ? I need to plot with lines not with "o" .
Reason for this is that matplotlib is ploting in order of first array. To solve this you need to sort first array.
Remember that the second table, if it is correlated with the first, must not be sorted, but the elements must be moved to their corresponding places from the new order of first array.
Assume that for example I want to plot a function like f(x)=a*x**2 in which "a" is parameter, in this way.
First, I plot the function with a=2 and run my code. Second, I sweep "a" to 4 and run my code again. By default Pycharm will plot two figures in two windows but I want them two be in one figure with different colors. It is easy to do this in MATLAB but in python the only way that I know is to use two "matplotlib.pyplot.plot" commands in my code and define "a" before each, twice. How can I do this as I want?
When I draw a picture using plot in pandas timeseries. I find a parameter named logy. I can't make sure how it works. The documents just say
Use log scaling on y axis
But I try figure it out and test log,log2...on y value.These values are different from the value which in the drawing window. So how plot(logy=True) works?