subplot

How can I make a blank subplot in matplotlib?

∥☆過路亽.° 提交于 2019-11-30 10:37:38
问题 I am making a group of subplot (say, 3 x 2) in matplotlib, but I have fewer than 6 datasets. How can I make the remaining subplot blank? The arrangement looks like this: +----+----+ | 0,0| 0,1| +----+----+ | 1,0| 1,1| +----+----+ | 2,0| 2,1| +----+----+ This may go on for several pages, but on the final page, there are, for example, 5 datasets to the 2,1 box will be empty. However, I have declared the figure as: cfig,ax = plt.subplots(3,2) So in the space for subplot 2,1 there is a default

How to plot pcolor colorbar in a different subplot - matplotlib

安稳与你 提交于 2019-11-30 08:48:56
I am trying to split my plots in different subplots.. What I want to achieve is to put a colorbar for a subplot in a different subplot. Right now I am using: # first graph axes = plt.subplot2grid((4, 2), (0, 0), rowspan=3) pc = plt.pcolor(df1, cmap='jet') # second graph axes = plt.subplot2grid((4, 2), (3, 0)) plt.pcolor(df2, cmap='Greys') # colorbar plt.subplot2grid((4, 2), (0, 1), rowspan=3) plt.colorbar(pc) But the result is the following (notice the unwanted empty graph left to the colorbar): What can I do to print only the colorbar without the left plot? Thanks colorbar() accepts a cax

how to remove the gap between subplots and around [duplicate]

天大地大妈咪最大 提交于 2019-11-30 07:03:26
This question already has an answer here: MATLAB subplot margin 3 answers I am plotting two subplots (2x1) in one figure. I would like to remove all the spacing between two subplots and remove the xlable and xlabel ticks for the top subplot too. Also, I am trying to remove all the spacing outside the subplot. I try set(gca, 'LooseInset', get(gca,'TightInset')) But it doesn't work. Now I am removing those margins and labels manually, I have 60 figures need to be handled and doing all those manually is time consuming. Any better way to do it? Thanks. I also try the subtightplot, it helps to

MATLAB: Plotting/Saving X-Y views of mesh function in subplots

点点圈 提交于 2019-11-29 23:59:16
问题 As the title says, I'm trying to save the 2-variable slices of a mesh function (as a .jpg, for example) as a subplot. I want to do this using a .m file because I have many plots to generate. I have figured out how to plot the views on their own figures, but I cannot get them to plot properly as subplots within a figure. To illustrate what I mean: Here are the outputs on individual plots: 3D mesh: 3D MATLAB mesh plot XY view: XY MATLAB mesh view YZ view: YZ MATLAB mesh view XZ view: XZ MATLAB

How can I make a blank subplot in matplotlib?

坚强是说给别人听的谎言 提交于 2019-11-29 21:12:04
I am making a group of subplot (say, 3 x 2) in matplotlib, but I have fewer than 6 datasets. How can I make the remaining subplot blank? The arrangement looks like this: +----+----+ | 0,0| 0,1| +----+----+ | 1,0| 1,1| +----+----+ | 2,0| 2,1| +----+----+ This may go on for several pages, but on the final page, there are, for example, 5 datasets to the 2,1 box will be empty. However, I have declared the figure as: cfig,ax = plt.subplots(3,2) So in the space for subplot 2,1 there is a default set of axes with ticks and labels. How can I programatically render that space blank and devoid of axes?

Plot something in one figure, and use it again later for another figure

て烟熏妆下的殇ゞ 提交于 2019-11-29 17:14:47
I hope I'm asking this question at the right place. I have a for-loop, in that many figures are created. After the loop is finished I want to produce one more figure with three of those earlier created plots as suplots. My code right now is like this: import numpy as np import matplotlib.pyplot as plt def f(t): return np.exp(-t)*np.cos(2*np.pi*t)+(t/10)**2. t1=np.arange(0.0,5.0,0.1) t2=np.arange(0.0,5.0,0.02) for i in range(2): fig= plt.figure(i) ax1=fig.add_subplot(111) plt.title('Jon Snow') kraft_plot,=ax1.plot(t1,np.sin(t1),color='purple') tyrion=ax1.axvline(2,color='darkgreen',ls='dashed')

Bar graph in subplot2grid

我只是一个虾纸丫 提交于 2019-11-29 16:50:32
I want to have several subplots, two of which showing frames from a video feed, and a third showing computed results as a bar graph. After creating a matplotlib figure, I create several subplot2grids, which I then update with FuncAnimation. The usual way I would create a bar graph (to be updated) is: fig = plt.figure() ax = plt.axes(xlim=(0, 9), ylim=(0, 100)) rects = plt.bar(res_x, res_y, color='b') def animate(args): ... ... for rect, yi in zip(rects, results): rect.set_height(yi*100) return rects anim = animation.FuncAnimation(fig, animate, frames=200, interval=20, blit=True) plt.show() I

Matplotlib: Getting subplots to fill figure

感情迁移 提交于 2019-11-29 14:10:12
I would please like suggestions for how to override the default matplotlib behaviour when plotting images as subplots, whereby the subplot sizes don't seem to match the figure size. I would like to set my figure size (e.g. to match the width of an A4 page) and have the subplots automatically stretch to fill the space available. In the following example, the code below gives a figure with a lot of white space between the panels: import numpy as np import matplotlib.pyplot as plt data=np.random.rand(10,4) #creating a wide figure with 2 subplots in 1 row fig,ax=plt.subplots(1,2, figsize=(9,3)) ax

Second subplot disappearing

≡放荡痞女 提交于 2019-11-29 10:37:34
I have a weird (and probably simple to solve) problem. I tried to plot (using panel) two plots: a1 = subplot(2,1,1, 'Parent', handles.cpd_plot, 'Position', [0.1, 0.4, 0.85, 0.45]); a2 = subplot(2,1,2, 'Parent', handles.cpd_plot, 'Position', [0.1, 0.1, 0.85, 0.15]); but after plotting a2, a1 disappears. I see that its some problem with position, when I lift up a1 a bit ( 'Position', [0.1, 0.5, 0.85, 0.45] ) its working (but it has to be >= 0.5). Where is the problem? Thanks! So it is probably happening because subplot deletes a plot when it is overlapping with the previous plot. I suspect that

How to create Pandas groupby plot with subplots?

半城伤御伤魂 提交于 2019-11-29 02:23:30
I have a data frame like this: value identifier 2007-01-01 0.781611 55 2007-01-01 0.766152 56 2007-01-01 0.766152 57 2007-02-01 0.705615 55 2007-02-01 0.032134 56 2007-02-01 0.032134 57 2008-01-01 0.026512 55 2008-01-01 0.993124 56 2008-01-01 0.993124 57 2008-02-01 0.226420 55 2008-02-01 0.033860 56 2008-02-01 0.033860 57 So I do a groupby per identifier: df.groupby('identifier') And now I want to generate subplots in a grid, one plot per group. I tried both df.groupby('identifier').plot(subplots=True) or df.groupby('identifier').plot(subplots=False) and plt.subplots(3,3) df.groupby(