subplot

Matplotlib sharex not working as expected

旧街凉风 提交于 2020-08-10 22:51:59
问题 I'm sure I am missing something obvious, but why is sharex=True, sharey=True not working? I expected the xlims and xticks to be the same for both subplots, and the ylims/yticks to be the same for both subplots. Using Python 3.8.3, matplotlib 3.2.1. x1, y1 = [(2,7,1), (6,2,2)] x2, y2 = [(8,3,0), (1,4,9)] fig, ax = plt.subplots(2,1, sharex=True, sharey=True, figsize=(15, 8)); ax1 = plt.subplot(2,1,1); ax1.scatter(x1, y1, c='red', label='Set1'); ax2 = plt.subplot(2,1,2); ax2.scatter(x2, y2, c=

Matplotlib 2 Subplots, 1 Colorbar

爱⌒轻易说出口 提交于 2020-06-28 09:39:48
问题 I've spent entirely too long researching how to get two subplots to share the same y-axis with a single colorbar shared between the two in Matplotlib. What was happening was that when I called the colorbar() function in either subplot1 or subplot2 , it would autoscale the plot such that the colorbar plus the plot would fit inside the 'subplot' bounding box, causing the two side-by-side plots to be two very different sizes. To get around this, I tried to create a third subplot which I then

Matplotlib Subplots Are Too Narrow With Tight Layout

余生长醉 提交于 2020-06-13 05:20:21
问题 I am currently trying to plot many subplots in Matplotlib (Python 3.6, Matplotlib 2.0.0) using GridSpec. Here is the minimal working example: import matplotlib.pyplot as plt from matplotlib.gridspec import * # Color vector for scatter plot points preds = np.random.randint(2, size=100000) # Setup the scatter plots fig = plt.figure(figsize=(8,8)) grid = GridSpec(9, 9) # Create the scatter plots for ii in np.arange(0, 9): for jj in np.arange(0, 9): if (ii > jj): ax = fig.add_subplot(grid[ii, jj]

Clearing a subplot in Matplotlib

♀尐吖头ヾ 提交于 2020-05-24 20:32:08
问题 I have a number of subplots in a figure fig1 , created via ax = fig1.add_subplot(221) I then plot stuff in each of the subplots via im=ax.plot(x,y) and add some axis labels via ax.set_xlabel('xlabel') I would then like to clear a specific subplot completely, as described in When to use cla(), clf() or close() for clearing a plot in matplotlib?. However the problem is that ax.cla() and ax.clear() seem to only clear the data from the plot, without removing the axes, axis tick labels etc. On the

Subfigures or Subcaptions with knitr that span more than one page?

好久不见. 提交于 2020-05-17 08:46:39
问题 Very similar to this post. However I have more plots than that fit on one page causing the remaining plots to be cut off after pressing Knit. Does any one know how to solve this by plotting the other plots on the next page? title: 'title' author: "--" date: "`r Sys.Date()`" output: pdf_document header-includes: - \usepackage{subfig} - \usepackage{float} ## To make the example more reproducible ## ```{r echo=FALSE, message=FALSE} knitr::opts_chunk$set(fig.width=6, fig.height=9, fig.show="hold"

Is there a way to normalize the scales of axes in subplots in cufflinks library python?

你。 提交于 2020-04-30 08:47:09
问题 I have used cufflinks to plot a few subplots, their scale ranges are different. I want same scales so I can compare the subplots. Is there a way to customize the axes of each subplot in cufflinks? This link shows the picture of the subplots, the subplots of row 1, column1 and column2 have different ranges on the y axes. Is there a way to change the range of graph DRV.FV to -5 to 10? MCVE: df=cf.datagen.lines(4) df.iplot(subplots=True, subplot_titles=True, legend=False) I have taken this from

Is there a way to normalize the scales of axes in subplots in cufflinks library python?

拜拜、爱过 提交于 2020-04-30 08:46:45
问题 I have used cufflinks to plot a few subplots, their scale ranges are different. I want same scales so I can compare the subplots. Is there a way to customize the axes of each subplot in cufflinks? This link shows the picture of the subplots, the subplots of row 1, column1 and column2 have different ranges on the y axes. Is there a way to change the range of graph DRV.FV to -5 to 10? MCVE: df=cf.datagen.lines(4) df.iplot(subplots=True, subplot_titles=True, legend=False) I have taken this from

matplotlib subplots - IndexError: too many indices for array

我的梦境 提交于 2020-04-18 06:14:29
问题 I'm plotting 8 columns into one figure by using subplots function. However, it shows "IndexError: too many indices for array" # -*- coding: utf-8 -*- import pandas as pd from matplotlib import pyplot as plt from matplotlib import style df = pd.read_csv('XXXX', encoding='utf-8') num = 0 for dim in ['A','B','C','D','E','F','G','H']: fig, axes = plt.subplots(nrows=8, ncols=1) df[dim].plot(ax=axes[num,0]) plt.xlabel(dim) num += 1 plt.show() 回答1: There are two problems with your code: First, you

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

我是研究僧i 提交于 2020-04-07 10:32:37
问题 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

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

江枫思渺然 提交于 2020-04-07 10:31:03
问题 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