Questions tagged [matplotlib-gridspec]

For questions related to matplotlib gridspec. Gridspec specifies the geometry of the grid that a subplot will be placed. The number of rows and number of columns of the grid need to be set. Optionally, the subplot layout parameters (e.g., left, right, etc.) can be tuned.

45 questions
1
vote
1 answer

How to add the colormap to the matplotlib 3d plot

I want to add the colormap to show the gradient along x axis but unfortunately the whole figure turns black. I might be lacking something kindly help me in this. Here is the code. import matplotlib.pyplot as plt from mpl_toolkits.mplot3d.art3d…
1
vote
1 answer

Issue with colorbar and imshow with gridspec

I wanted to plot 2 imshow on a figure, but I only want the sub figure on the right to have the colorbar at the bottom of its plot. import matplotlib.pyplot as plt import numpy as np from matplotlib.gridspec import GridSpec cm = 1/2.54 fig =…
1
vote
1 answer

How to adjust gridspec spacing

I have a matplotlib plot with 3x2 subplots. I want no spacing between the columns (achieved), and no spacing between the first (a, b) and the second row (c, d). However, the third row (e, f) should be well separated from the second, as it has…
laolux
  • 1,445
  • 1
  • 17
  • 28
1
vote
1 answer

How do I get subplot and GridSpec to position and size subplots?

I am trying to create a figure with 2x10 subplots. I would like them all to be square with a thin white space in between them, but they are coming out as rectangles (longer in height than width). The images I'm putting in each cell of the grid are…
1
vote
1 answer

How to use Cartopy with gridspec

I would like to create a plot with a Cartopy plot on the left-hand side and two stacked Matplotlib plots on the right-hand side. If I'd only use Matplotlib plots, the code would be as follows. import matplotlib.gridspec as gridspec import…
Stücke
  • 868
  • 3
  • 14
  • 41
1
vote
1 answer

Retain square layout with GridSpec

How do I align the GridSpec to look like this? |‾ ‾ ‾ ‾| |‾ ‾| |‾ ‾| | | |_ _| |_ _| | | |‾ ‾| |‾ ‾| |_ _ _ _| |_ _| |_ _| I have tried the following: import matplotlib.pyplot as plt from matplotlib.gridspec import…
Kevin
  • 3,096
  • 2
  • 8
  • 37
1
vote
2 answers

Too much space between subplots with gridspec

I am trying to make a figure with a grid of 12 plots on the left and one larger plot on the right. The problem is that matplotlib adds far too much space between the small subplots. How can I get rid of this space? import matplotlib.pyplot as…
Onno Eberhard
  • 1,341
  • 1
  • 10
  • 18
1
vote
1 answer

How to format a shared y-axis with gridspec

I'm trying to fix the format for this plot: that I'm generating with "Df" data, but I'm having this cumbersome issue in which both plots are too close. The script I'm using to plot this is: #[Df,mdD,teoD,e1f,teoe1,e2f,teoe2] = [[row[i] for row in…
nuwe
  • 177
  • 9
1
vote
1 answer

Automatically get the dimensions or indices of gridspec axes

Given a gridspec object in matplotlib, I want to automatically iterate through all its indices so I can add the corresponding Axes automatically, something like: for i, j in gspec.indices: # whatever those indices are axs[i,j] =…
irene
  • 2,085
  • 1
  • 22
  • 36
1
vote
1 answer

How to create a twin axes with gridspec

I am using two GridSpec objects to generate the following plot: import numpy as np import matplotlib.pyplot as plt from matplotlib.figure import figaspect plt.rcParams.update({'figure.figsize' : (10,10)}) plt.rcParams.update({'font.size' :…
Luismi98
  • 282
  • 3
  • 14
1
vote
1 answer

How to specify subplots layout with gridspec

I'm trying to use plt.GridSpec() to set up two subplots such that the left one takes up about 67% of the space and the right one takes up 33%. I looked at the documentation, but I just can't seem to figure out how to set up the indexing--probably…
a11
  • 3,122
  • 4
  • 27
  • 66
1
vote
1 answer

Adding figures with gridspec

I am trying to create a plot similar to the one from this question. Why am I only getting two pannels, i.e. just gs2: import numpy as np import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec def main(): fig = plt.figure() gs1…
Sebastiano1991
  • 867
  • 1
  • 10
  • 26
0
votes
0 answers

How to adjust colorbar height in Gridspec subplots

How can I produce 1x15 subplots where the first and second columns are filled contour and the third column will have two stacked horizontal line plots in each of the rows? The code below is an example but I want the line plots in the third column to…
0
votes
1 answer

How to create subplots using Gridspec

How can I produce 3x3 subplots where the first and second columns are filled contour and the third column will have two stacked horizontal line plots in each of the rows? This is the kind of layout (not to scale) that I want. Any generic answer will…
Rocc
  • 3
  • 2
0
votes
0 answers

embedded gridspec with loop object not subscriptable

I am trying to create a 4X4 matrix of gridspec by iteration and embedding new gridspec inside the previous ones. I am using GridSpecFromSubplot, but I got the error ''SubplotSpec' object is not subscriptable'. I am attaching the code I am trying to…