subplot

Python - Organisation of 3 subplots with matplotlib

点点圈 提交于 2019-12-03 01:25:18
I try to generate 3 subplots for my figure. It seems work but it is not perfectly aligned. How to have the same width between the figure at the bottom et the figures at below? plt.close() fig = plt.figure() ax1 = plt.subplot(211) ax1.plot(cycles,np.asarray(df_int),'wo',label='') ax1.plot(cycles,np.asarray(df_proj),'k+',label='') ax1.legend(loc=2) #ax1.subplots_adjust(left=0.15) ax1.set_ylim(0.001,0.004) ax2 = plt.subplot(223) i2=ax2.imshow(c,cmap=plt.cm.hot, vmin=-5, vmax=5);#plt.colorbar();plt.clim(-5,5) cb2=plt.colorbar(i2,ax=ax2,ticks=[-5,0,5],fraction=0.046, pad=0.04,format='%.2f') cb2.ax

Removing frame while keeping axes in pyplot subplots

不羁岁月 提交于 2019-12-02 22:35:16
I am creating a figure with 3 subplots, and was wondering if there is any way of removing the frame around them, while keeping the axes in place? If you want to remove the axis spines, but not the other information (ticks, labels, etc.), you can do that like so: fig, ax = plt.subplots(7,1, sharex=True) t = np.arange(0, 1, 0.01) for i, a in enumerate(ax): a.plot(t, np.sin((i + 1) * 2 * np.pi * t)) a.spines["top"].set_visible(False) a.spines["right"].set_visible(False) a.spines["bottom"].set_visible(False) or, more easily, using seaborn : fig, ax = plt.subplots(7,1, sharex=True) t = np.arange(0,

Updating bar and plot subplots over loop iterations

北城余情 提交于 2019-12-02 17:48:50
问题 I wrote the following snippet and I am trying to make it update the plots. What I get instead is an overlapping of new plots on the old ones. I researched a bit and found I needed relim() and autoscale_view(True,True,True) on the current axis. I still cannot get the desired behaviour. Is there a way to force pyplot to delete/remove the old drawing before calling plt.draw()? import numpy as np import matplotlib.pyplot as plt import time plt.ion() a = np.arange(10) fig,ax = plt.subplots(2,1)

Align subplot with colorbar

十年热恋 提交于 2019-12-02 17:33:47
问题 I am trying to share the x-axis of a imshow that have to be square and a classique plot: the imshow has to be square with a colorbar the plot bellow should share the same axis (or at least look like align with the imshow) I spent two days on it, and now I am crazy. Did someone know how to align them ? The code used to produce the image is bellow. def myplot( Nbin=20 ): X = np.random.rand(1000) Y = np.random.rand(1000) h2, yh2, xh2 = np.histogram2d( Y, X, bins=[Nbin,Nbin] ) h1, xh1 = np

How can make subplots of columns in Pandas dataframe in one window inside of for-loop

谁说胖子不能爱 提交于 2019-12-02 15:31:51
问题 * Please help it's very important: Why is not possible to get subplots of cloumns of Pandas dataframe by using HeatMap inside of for-loop? I am trying to create subplots of columns in pandas dataframe inside of for-loop during iterations since I plot result for every cycle that is for each 480 values to get all 3 subplots belong to A, B, C side by side in one window. I've found only one answer here which I'm afraid is not my case! @euri10 answered by using flat. My scripts are following: #

Plot a big figure with many subfigures in matlab

北城余情 提交于 2019-12-02 11:50:11
问题 I have to print a large poster, containing a matrix of figures, and it would be very practical for me to let MATLAB arrange them. Unluckily, subplots are displayed to fit a certain figure size, so are tiny and distorted. Instead of fitting the figure size, I would like to fit the paper size of my poster. I have tried with set(gcf,'Position'..) , and also changing papersize, but I still don't see the expected result. Is there something I can try to let MATLAB use, say, a whole A0 sheet to plot

adjusting subplot with a colorbar

江枫思渺然 提交于 2019-12-02 11:25:41
I have made the following visualization. I am at loss to figure out how to adjust the size of the third subplot according to the other two (they are sharing the x-axis). The properties that are given here are not helping much and the examples I found on SO also seem to be addressing cases different from mine. Can anyone please help? An easy method would be to add another two colorbars but make them invisible. import matplotlib.pyplot as plt fig, (ax,ax2,ax3) = plt.subplots(3,1, sharex=True) ax.plot([1,3,5],[1,2,5]) ax2.plot([3,5,9],[4,2,2]) ax3.plot([5,7,12],[1,5,3]) sm = plt.cm.ScalarMappable

matplotlib subplot without gaps but the last one

自古美人都是妖i 提交于 2019-12-02 11:19:49
I'm try to figure out how can I achieve the result as reported in the title's topic, basically I wish obtain a subplot 1 column 4 row without gaps in the row 1,2,3 and a normal gaps between the 1,2,3 block and the four Right now I have just obtain a 4 row plot without gaps using the subplot_adjust as follow: fig.subplots_adjust(wspace=0, hspace=0) here the complete code: fig,axs = SansItalic(**{'lines.linewidth': 3} )(4,1,(14.0,14.0)) axs[0].plot(a1,a2,label='45 60',color='C5') # ,linestyle=(0, (1, 1))) axs[0].plot(a13,a14,label='57 75',color='C4') #,linestyle=(0, (1, 1))) axs[1].plot(a11,a12

Updating bar and plot subplots over loop iterations

ⅰ亾dé卋堺 提交于 2019-12-02 10:54:42
I wrote the following snippet and I am trying to make it update the plots. What I get instead is an overlapping of new plots on the old ones. I researched a bit and found I needed relim() and autoscale_view(True,True,True) on the current axis. I still cannot get the desired behaviour. Is there a way to force pyplot to delete/remove the old drawing before calling plt.draw()? import numpy as np import matplotlib.pyplot as plt import time plt.ion() a = np.arange(10) fig,ax = plt.subplots(2,1) plt.show() for i in range(100): b = np.arange(10) * np.random.randint(10) ax[0].bar(a,b,align='center')

Python keeps overwriting hist on previous plot but doesn't save it with the desired plot

强颜欢笑 提交于 2019-12-02 07:58:06
I am saving two separate figures, that each should contain 2 plots together. The problem is that the first figure is ok, but the second one, does not gets overwritten on the new plot but on the previous one, but in the saved figure, I only find one of the plots : This is the first figure , and I get the first figure correctly : import scipy.stats as s import numpy as np import os import pandas as pd import openpyxl as pyx import matplotlib matplotlib.rcParams["backend"] = "TkAgg" #matplotlib.rcParams['backend'] = "Qt4Agg" #matplotlib.rcParams['backend'] = "nbAgg" import matplotlib.pyplot as