matplotlib

Matplotlib: 3 plots plotted in 2 rows with single image centered

自作多情 提交于 2021-02-18 07:09:00
问题 I have a 3 figure plot. I would like to have two rows of images with 2 plots on the top row, and 1 on the bottom. I need to center align the single plot on the second row. fig, ax = plt.subplots(nrows=2, ncols=2) x = np.arange(0.01,1.01,0.01) y = np.arange(0.01,1.01,0.01) X,Y = np.meshgrid(x, y) # grid of point Z = 1/((1/X)+(1/Y)-1) F = Y / X values = [0.3, 0.5, 0.8, 1.0, 1.3, 1.5, 2.0, 3.0, 5.0, 10.0] #Plot 0 ax[0,0].set_aspect('equal') CS = ax[0,0].contour(X,Y,Z,np.arange(0.1,1.0,0.1)

Matplotlib: 3 plots plotted in 2 rows with single image centered

感情迁移 提交于 2021-02-18 07:06:11
问题 I have a 3 figure plot. I would like to have two rows of images with 2 plots on the top row, and 1 on the bottom. I need to center align the single plot on the second row. fig, ax = plt.subplots(nrows=2, ncols=2) x = np.arange(0.01,1.01,0.01) y = np.arange(0.01,1.01,0.01) X,Y = np.meshgrid(x, y) # grid of point Z = 1/((1/X)+(1/Y)-1) F = Y / X values = [0.3, 0.5, 0.8, 1.0, 1.3, 1.5, 2.0, 3.0, 5.0, 10.0] #Plot 0 ax[0,0].set_aspect('equal') CS = ax[0,0].contour(X,Y,Z,np.arange(0.1,1.0,0.1)

Matplotlib: 3 plots plotted in 2 rows with single image centered

那年仲夏 提交于 2021-02-18 07:06:09
问题 I have a 3 figure plot. I would like to have two rows of images with 2 plots on the top row, and 1 on the bottom. I need to center align the single plot on the second row. fig, ax = plt.subplots(nrows=2, ncols=2) x = np.arange(0.01,1.01,0.01) y = np.arange(0.01,1.01,0.01) X,Y = np.meshgrid(x, y) # grid of point Z = 1/((1/X)+(1/Y)-1) F = Y / X values = [0.3, 0.5, 0.8, 1.0, 1.3, 1.5, 2.0, 3.0, 5.0, 10.0] #Plot 0 ax[0,0].set_aspect('equal') CS = ax[0,0].contour(X,Y,Z,np.arange(0.1,1.0,0.1)

Seaborn PairGrid: show axes labels for each subplot

痞子三分冷 提交于 2021-02-18 07:00:28
问题 Is there a way that I can easily add the axes labels for each of the subplots in Seaborn pair plot? This is related to this question but instead of adding the tick labels I want to add the axes labels as the pairplot I am having is 9*9 and I dont want to scroll down every time to check the column name. I was hoping that it would be some thing easy like for ax in g.axes.flat: _ = plt.setp(ax.get_ylabels(), visible=True) _ = plt.setp(ax.get_xlabels(), visible=True) 回答1: You first need to get

Matplotlib table formatting column width

爷,独闯天下 提交于 2021-02-18 06:42:08
问题 I wish to format one column of a table but when iterating through the rows it appears the width of the column width changes after each iteration. Source Code def p_create_table(self, events, dates, rows, columns, portfolio): """ :param events: Dict - {Date:Event} where Event is a String identifying what event happened :param dates: List - Dates of events :param rows: Int - number of Dates (rows) to create for the table :param columns: List - Column headers :param portfolio: Dataframe -

Matplotlib table formatting column width

China☆狼群 提交于 2021-02-18 06:42:08
问题 I wish to format one column of a table but when iterating through the rows it appears the width of the column width changes after each iteration. Source Code def p_create_table(self, events, dates, rows, columns, portfolio): """ :param events: Dict - {Date:Event} where Event is a String identifying what event happened :param dates: List - Dates of events :param rows: Int - number of Dates (rows) to create for the table :param columns: List - Column headers :param portfolio: Dataframe -

Using Mayavi to make 3D graphs, with Matplotlib-style axes

荒凉一梦 提交于 2021-02-18 05:44:55
问题 I've been messing around with Mayavi for 3D graphing, and I can graph the scatter plot I want but can't seem to get the Axes to look proper. I found the following previous question that starts to get at what I'm after, but doesn't go into detail. I want a 3D scatter plot like #1 but with nice-looking axes like #2 (I'd embed but I don't have enough reputation). The regular Mayavi Axes aren't going to cut it. Any tips for getting the planes that Matplotlib has? 回答1: This is actually pretty

Using Mayavi to make 3D graphs, with Matplotlib-style axes

ε祈祈猫儿з 提交于 2021-02-18 05:43:16
问题 I've been messing around with Mayavi for 3D graphing, and I can graph the scatter plot I want but can't seem to get the Axes to look proper. I found the following previous question that starts to get at what I'm after, but doesn't go into detail. I want a 3D scatter plot like #1 but with nice-looking axes like #2 (I'd embed but I don't have enough reputation). The regular Mayavi Axes aren't going to cut it. Any tips for getting the planes that Matplotlib has? 回答1: This is actually pretty

How to label a seaborn contour plot

梦想与她 提交于 2021-02-18 05:32:58
问题 So I'm using seaborn to make a kdeplot with sns.kdeplot(x, y, ax=plt.gca(), cmap="coolwarm") . I can change the levels with the levels kwarg but I want to be able to label the contours as well. In matplotlib you would simply do plt.clabel(CS, CS.levels, inline=True) but seaborn doesn't return the contour collection CS . How would I do this? Or do I just have to do it all from scratch myself? Edit: Is there maybe a way to make a wrapper which will also return CS? I can't see how though... 回答1:

Making a Python Fan Chart / Fan Plot

孤者浪人 提交于 2021-02-17 20:54:13
问题 I'm looking to make a fan chart type line plot in Python which resembles the Bank of England Interest Rate fan charts like this one: I'm quite well practiced with using matplotlib for standard line/bar/scatter plots, however this seems like it would require something of a more custom implementation. I've Google'd about and cannot seem to find any standard libraries for Python that do this sort of thing at all or even any code that describes how this might be done. Any help on how this could