subplot

Problem with plotting graphs in 1 row using plot method from pandas

删除回忆录丶 提交于 2019-12-20 03:52:27
问题 Suppose I want to plot 3 graphs in 1 row: dependencies cnt from other 3 features. Code: fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(15, 10)) for idx, feature in enumerate(min_regressors): df_shuffled.plot(feature, "cnt", subplots=True, kind="scatter", ax= axes[0, idx]) plt.show() Error message: IndexErrorTraceback (most recent call last) <ipython-input-697-e15bcbeccfad> in <module>() 2 fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(15, 10)) 3 for idx, feature in enumerate(min

Changing size of matplotlib subplots

北城以北 提交于 2019-12-20 03:06:43
问题 Is there an easy way to modify this code so that the plots are bigger without changing the scale on the axes? import numpy as np import matplotlib.pyplot as plt import math %matplotlib inline a, c = -10, 10 x = np.linspace(a,c,100) x = np.array(x) def y(x): return np.arctan(x) h = 0.0000001 def grad(x,h): return (y(x+h)-y(x))/h m = grad(x,h) plt.figure(1) plt.subplot(121) plt.plot(x, y(x), 'b') plt.xlim([a,c]) plt.ylim([min(y(x)),max(y(x))]) plt.gca().set_aspect('equal', adjustable='box') plt

Tight subplot with colorbars and subplot's 3rd parameter in Matlab?

眉间皱痕 提交于 2019-12-19 11:46:22
问题 I would like to have a tight subplot i.e. minimum spacing between figures in the subplot where you have subplot's 3rd parameter i.e. you can decide where the picture is going to be i.e. easy to move between subplot and new_tight_subplot , and you can use it with colorbars. I have profiled the most popular tight subplots in FileExchange of Matlab. None (etc most popular here Pekka's version) can pass the following code data=randi(513,513); ax1=subplot(2,1,1); plot(mat2gray(pdist(data,

Matplotlib - Broken axis example: uneven subplot size

老子叫甜甜 提交于 2019-12-19 04:03:31
问题 I haven't found a solution to adjust the height of the bottom and top plot of the broken axis example of matplotlib. BTW: The space between the two plots can be adjusted by: plt.subplots_adjust(hspace=0.03) UPDATE: I've almost figured it out using gridspec: """ Broken axis example, where the y-axis will have a portion cut out. """ import matplotlib.pylab as plt # NEW: import matplotlib.gridspec as gridspec import numpy as np pts = np.array([ 0.015, 0.166, 0.133, 0.159, 0.041, 0.024, 0.195, 0

Matplotlib odd subplots

风流意气都作罢 提交于 2019-12-19 03:24:27
问题 I have to plot a figure with 11 subpots as you can see below. But as it is an odd number, i dont know how to deal the subplot (4,3,12) to remove it... and place the 2 last plots on the center Moreover i would like to increse the subplot size as the space is too important. The code is below. The code is : plt.close() fig, axes = plt.subplots(nrows=4, ncols=3) plt.tight_layout(pad=0.05, w_pad=0.001, h_pad=2.0) ax1 = plt.subplot(431) # creates first axis ax1.set_xticks([]) ax1.set_yticks([]) ax1

Set size of subplot in matplotlib

半世苍凉 提交于 2019-12-18 15:10:46
问题 I wonder how to set the size of the subplot when figure contains multiple subplots (5 × 2 in my case). No matter how big I allow the whole figure to be, the subplots always seem to be small. I would like to have direct control of the size of the subplot in this figure. The simplified version of the code is pasted below. import numpy as np import matplotlib.pyplot as plt x = np.random.randn(20) y = np.random.randn(20) fig = plt.figure(figsize=(20, 8)) for i in range(0,10): ax = fig.add_subplot

Set size of subplot in matplotlib

回眸只為那壹抹淺笑 提交于 2019-12-18 15:09:58
问题 I wonder how to set the size of the subplot when figure contains multiple subplots (5 × 2 in my case). No matter how big I allow the whole figure to be, the subplots always seem to be small. I would like to have direct control of the size of the subplot in this figure. The simplified version of the code is pasted below. import numpy as np import matplotlib.pyplot as plt x = np.random.randn(20) y = np.random.randn(20) fig = plt.figure(figsize=(20, 8)) for i in range(0,10): ax = fig.add_subplot

How to plot pcolor colorbar in a different subplot - matplotlib

你说的曾经没有我的故事 提交于 2019-12-18 13:14:27
问题 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

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

杀马特。学长 韩版系。学妹 提交于 2019-12-18 12:36:30
问题 This question already has answers here : MATLAB subplot margin (3 answers) Closed 3 years ago . 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

Bar graph in subplot2grid

此生再无相见时 提交于 2019-12-18 09:32:41
问题 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)