subplot

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

独自空忆成欢 提交于 2020-04-07 10:28: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

How can I do subplots in matplotlib with differents xlimit and size of axis-x?

余生颓废 提交于 2020-03-26 03:50:49
问题 How can I solve this? I want to do 4 subplots with matplotlib, I have used the subplot option but the result is just a big plot. I don't have idea what is the problem. I want to see four subplots, each one with title, and a suptitle for them. I don't have idea how can I solve it? Can you help me please to fix it? Thanks a lot #!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals from matplotlib.collections import LineCollection import matplotlib.patches as

How to adjust space between every second row of subplots in matplotlib

♀尐吖头ヾ 提交于 2020-03-18 06:20:47
问题 I'm hoping to adjust the space between subplots horizontally. Specifically between every second row. I can adjust every row using fig.subplots_adjust(hspace=n) . But is it possible to apply this to every 2nd row? import matplotlib.pyplot as plt fig, ax = plt.subplots(figsize = (10,10)) plt.style.use('ggplot') ax.grid(False) ax1 = plt.subplot2grid((5,2), (0, 0)) ax2 = plt.subplot2grid((5,2), (0, 1)) ax3 = plt.subplot2grid((5,2), (1, 0)) ax4 = plt.subplot2grid((5,2), (1, 1)) ax5 = plt

How to adjust space between every second row of subplots in matplotlib

柔情痞子 提交于 2020-03-18 06:18:39
问题 I'm hoping to adjust the space between subplots horizontally. Specifically between every second row. I can adjust every row using fig.subplots_adjust(hspace=n) . But is it possible to apply this to every 2nd row? import matplotlib.pyplot as plt fig, ax = plt.subplots(figsize = (10,10)) plt.style.use('ggplot') ax.grid(False) ax1 = plt.subplot2grid((5,2), (0, 0)) ax2 = plt.subplot2grid((5,2), (0, 1)) ax3 = plt.subplot2grid((5,2), (1, 0)) ax4 = plt.subplot2grid((5,2), (1, 1)) ax5 = plt

How to adjust space between every second row of subplots in matplotlib

▼魔方 西西 提交于 2020-03-18 06:17:53
问题 I'm hoping to adjust the space between subplots horizontally. Specifically between every second row. I can adjust every row using fig.subplots_adjust(hspace=n) . But is it possible to apply this to every 2nd row? import matplotlib.pyplot as plt fig, ax = plt.subplots(figsize = (10,10)) plt.style.use('ggplot') ax.grid(False) ax1 = plt.subplot2grid((5,2), (0, 0)) ax2 = plt.subplot2grid((5,2), (0, 1)) ax3 = plt.subplot2grid((5,2), (1, 0)) ax4 = plt.subplot2grid((5,2), (1, 1)) ax5 = plt

Grids of Subplots with 3D Polycollection

六月ゝ 毕业季﹏ 提交于 2020-02-26 02:17:23
问题 Create a grid of 3D Subplots using mplot3d Polycollection (or another mplot3d library) Here is a simple mplot3d example (you can see here: https://matplotlib.org/2.0.2/examples/mplot3d/polys3d_demo.html) : from mpl_toolkits.mplot3d import Axes3D from matplotlib.collections import PolyCollection import matplotlib.pyplot as plt from matplotlib import colors as mcolors import numpy as np fig = plt.figure() ax = fig.gca(projection='3d') xs = np.arange(0, 10, 0.4) verts = [] zs = [0.0, 1.0, 2.0, 3

Grids of Subplots with 3D Polycollection

让人想犯罪 __ 提交于 2020-02-26 02:14:50
问题 Create a grid of 3D Subplots using mplot3d Polycollection (or another mplot3d library) Here is a simple mplot3d example (you can see here: https://matplotlib.org/2.0.2/examples/mplot3d/polys3d_demo.html) : from mpl_toolkits.mplot3d import Axes3D from matplotlib.collections import PolyCollection import matplotlib.pyplot as plt from matplotlib import colors as mcolors import numpy as np fig = plt.figure() ax = fig.gca(projection='3d') xs = np.arange(0, 10, 0.4) verts = [] zs = [0.0, 1.0, 2.0, 3

Matplotlib - Different tick label alignment along the same axis

六眼飞鱼酱① 提交于 2020-02-22 12:46:18
问题 I have a figure with a lot of subplot, such that the last ticklabel of an axis is written over the first tick label of the next one. See example here As I want to keep the spacing between the subplots as I set it, I would like to have a different alignment depending on the tick, as it could be produced by : plt.xticks([0], ha = 'left') plt.xticks([0.2,0.4], ha = 'center') plt.xticks([0.6], ha = 'right') Using that, only the last call of xticks is shown on the figure. In another way, the idea

populating matplotlib subplots through a loop and a function

早过忘川 提交于 2020-02-18 05:13:09
问题 I need to draw subplots of a figure through loop iterations; each iteration calls a function defined in another module (=another py file), which draws a pair of subplots. Here is what I tried -- and alas does not work: 1) Before the loop, create a figure with the adequate number of rows, and 2 columns: import matplotlib.pyplot as plt fig, axarr = plt.subplots(nber_rows,2) 2) Inside the loop, at iteration number iter_nber, call on the function drawing each subplot: fig, axarr = module.graph

Plot all pandas dataframe columns separately

自作多情 提交于 2020-01-23 17:32:25
问题 I have a pandas dataframe who just has numeric columns, and I am trying to create a separate histogram for all the features ind group people value value_50 1 1 5 100 1 1 2 2 90 1 2 1 10 80 1 2 2 20 40 0 3 1 7 10 0 3 2 23 30 0 but in my real life data there are 50+ columns, how can I create a separate plot for all of them I have tried df.plot.hist( subplots = True, grid = True) It gave me an overlapping unclear plot. how can I arrange them using pandas subplots = True. Below example can help