This creates a new subplot in the first position - see the subplot documentation. # 2nd alternative - this plot is not scrollable: Calling ax.legend() draws the legend based on the label and stroke you provided. This plots the your oscillations into the first subplot that you created when you called plt.subplots, since you're calling plot on ax. # 1st alternative - this plot is scrollable: It's not completely clear to me what you want to do here, so I'll start with 5. And finally the difference between 1st and 2nd alternative? The most important: how to make it work for three subplots?ĥ. In that case, it doesn't matter which axis you update, since the sharex behavior will update this value for both axes.īut, try updating the y min and max - updating axis properties won't be the same in that case.Ĥ. You are only updating the xmin and xmax in any case, since you initialized ymin=-1 and ymax=1 (see 2.). Since the axes were originally created with a ymin of -1 and a ymax of 1, calling update doesn't change the axes in either case. You created the subplots with the kwargs sharex=True and sharey=False. No matter which index is chosen (0 or 1), it behaves exactly the same in both alternatives. It's a little weird that you're setting the axis of the plt object - but, doing so sets the axis once-only on the last subplot.ģ. This sets the plot's axis limits, in the form. On which plots this option is apply to (already existed or also for subplots created in future)? Comment out that line to see what I mean.Ģ. In this example, this is necessary to prevent the slider from colliding with the rest of the figure. So, calling plt.subplots_adjust(bottom=0.25) makes the bottom margin of the whole plot (area containing both subplots) 25% of the figure height. The bottom of the subplots of the figure. These all update the subplot parameters, which are all documented here:Īll dimensions are fraction of the figure width or height bottom: Subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None) On which (sub)plots this option is apply to (already existed or also for subplots created in future)? Your questions can all be answered from the matplotlib.figure API documentation or the matplotlib.pyplot API documentation.ġ. And finally the difference between 1st and 2nd alternative?Īx.plot(x_time, sin_s, "bo-", label="sin")Īx.plot(x_time, cos_s, "r.-", label="cos").The most important: how to make it work for three subplots?.comment regarding: ax.axis() vs ax.axis().comment regarding: plt.subplots_adjust(bottom=0.25).And if I use 2nd alternative then I get just two subplots instead of three, where one is scrollable and another is not.Ĭan you please answer following questions: So I've changed nrows=2 to nrows=3 in following line:īut if I use 1st alternative then all three subplots are scrollable, instead of two. I've tried to combine those examples into my final solution (having three plots from which the two are scrollable). Plt.plot(x_time, oscil, "k-", label="oscilation") Here are two different parts of code that I use for plotting, this is the trial and error part of code that I do not understand: # 1st alternative - this plot is scrollable:Īx.plot(x_time, oscil, "k-", label="oscilation") # it behaves exactly the same in both alternatives. No matter which index is chosen (0 or 1), On which plots this option is apply toĪxpos = plt.axes(, axisbg=axcolor) Oscil = np.cos(2 * np.pi * x_time) * np.exp(-x_time) # (already existed or also for subplots created in future)? On which (sub)plots this option is apply to The tricky part is plotting part, which was mainly created as trial and error: #!/usr/bin/pythonįig, ax = plt.subplots(nrows=2, ncols=1, sharex=True, sharey=False) I've modified a bit the code from answer to my another question. The first subplot should not use the slider widget, other two should, so if I will move slider then two bottom subplots should scroll. Those subplots should be aligned in one column, each one under another. My goal is to create three subplots in same window.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |