# and do something with it (you know best what to do with it)Īx = plt.subplot2grid((nr, nc), next(pos))Īx.text(0.5, 0.5, worker, va="center", ha="center", transform=ax. # for each worker we place an axes on the correct position Pos = iter((i, j) for i in range(nr) for j in range(nc)) # an iter object to keep track of the subplot position # in any case we instantiate a new figure and # if iw>0 we have a completed figure to ship out # we are at the start OR we have completed a figure # the loop is on an enumerated sequence of workers and valuesįor iw, (worker, values) in enumerate(ems()): # Put the raw data in a more useful data structure, for me a dict # the data in the OP, edited to get a syntactically correct object. ![]() # wrt the previous version I have reduced the number of row and cols I tried to use the scarce data the OP provided (very few point, syntactically erroneous, not the real data structure they used in the code snippet) to elaborate a more complete answer (my previous one is still available in the edit history) import matplotlib.pyplot as plt ![]() I want to show all of the subplots for my n workers, so I tried to show 8 subplots per figure, by changing fig, ax = plt.subplots(len(steps), len(steps)) to fig, ax = plt.subplots(4, 4), and now I get only the 8 first workers subplots, instead of all of them.Ĭan anyone help me on this? How to show for example 8 subplots per figure, but show all of the subplots, not only the first 8? My current code outputs this ugly figure: fig, ax = plt.subplots(len(steps), len(steps))Īx = ax.ravel() # all subaxes in single numpy array, to easily iterate overĪx_sub.plot(range(ls), for k in steps]) python-matplotlib How to set more space between subplots Use subplotsadjust () method to set subplots spacing: import matplotlib.pyplot as plt fig, axes plt.subplots (nrows1, ncols2) axes 0.plot ( 1,3,2) axes 1.plot ( 8,2,5) plt.subplotsadjust (wspace0.6, hspace0.6) plt. So, I want to make subplots (one for each worker), where each one has at x-axis the iteration step and at y-axis their corresponding value. I want to plot how each value changes in each step for every worker. In my code, at each iteration step I get a list of tuples that contain a worker_id and a value, like this:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |