Questions tagged [figure]

A container for images, plots or other graphical elements with some optional meta-information.

A figure is a container that encompasses graphical elements in a larger context.

Matlab

From the official docs:

A figure is a MATLAB window that contains graphic displays (usually data plots) and UI components. You create figures explicitly with the figure function, and implicitly whenever you plot graphics and no figure is active."

LaTeX

A figure is a kind of float, a container for things that can't be split over different pages. A figure is define with the equally named environment.

HTML5

The <figure> Element represents self-contained content, frequently with a caption (), and is typically referenced as a single unit. (From the Mozilla HTML docs)

1521 questions
632
votes
6 answers

How do I change the figure size with subplots?

How do I increase the figure size for this figure? This does nothing: f.figsize(15, 15) Example code from the link: import matplotlib.pyplot as plt import numpy as np # Simple data to display in various forms x = np.linspace(0, 2 * np.pi, 400) y =…
Brian
  • 13,996
  • 19
  • 70
  • 94
584
votes
7 answers

What does the argument mean in fig.add_subplot(111)?

Sometimes I come across code such as this: import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y = [1, 4, 9, 16, 25] fig = plt.figure() fig.add_subplot(111) plt.scatter(x, y) plt.show() Which produces: I've been reading the documentation like…
pleasedontbelong
  • 19,542
  • 12
  • 53
  • 77
394
votes
6 answers

Matplotlib different size subplots

I need to add two subplots to a figure. One subplot needs to be about three times as wide as the second (same height). I accomplished this using GridSpec and the colspan argument but I would like to do this using figure so I can save to PDF. I can…
Jason Strimpel
  • 14,670
  • 21
  • 76
  • 106
337
votes
5 answers

Savefig outputs blank image

I am trying to save plots I make using matplotlib; however, the images are saving blank. Here is my code: plt.subplot(121) plt.imshow(dataStack, cmap=mpl.cm.bone) plt.subplot(122) y = copy.deepcopy(tumorStack) y = np.ma.masked_where(y == 0,…
tylerthemiler
  • 5,496
  • 6
  • 32
  • 40
207
votes
6 answers

How do I tell Matplotlib to create a second (new) plot, then later plot on the old one?

I want to plot data, then create a new figure and plot data2, and finally come back to the original plot and plot data3, kinda like this: import numpy as np import matplotlib as plt x = arange(5) y = np.exp(5) plt.figure() plt.plot(x, y) z =…
Peter D
  • 3,283
  • 4
  • 24
  • 23
170
votes
8 answers

Python Matplotlib figure title overlaps axes label when using twiny

I am trying to plot two separate quantities on the same graph using twiny as follows: fig = figure() ax = fig.add_subplot(111) ax.plot(T, r, 'b-', T, R, 'r-', T, r_geo, 'g-') ax.set_yscale('log') ax.annotate('Approx. sea level',…
Magic_Matt_Man
  • 2,020
  • 3
  • 16
  • 16
164
votes
8 answers

Error in plot.new() : figure margins too large, Scatter plot

I've looked in different questions for a solution and I've tried what was suggested but I have not found a solution to make it work. Everytime I want to run this code it always says: Error in plot.new() : figure margins too large and I don't know…
user3530361
  • 1,651
  • 2
  • 11
  • 5
128
votes
7 answers

How do I make a reference to a figure in markdown using pandoc?

I'm currently writing a document in markdown and I'd like to make a reference to an image from my text. this is my text, I want a reference to my image1 [here]. blablabla ![image1](img/image1.png) I want to do that reference because after…
Romain Piel
  • 11,017
  • 15
  • 71
  • 106
97
votes
8 answers

How to force two figures to stay on the same page in LaTeX?

I have two images that I want to display on a page as figures. Each eats up little less than half of the space available so there's not much room for any other stuff on that page, but I know there is enough space for both of the figures. I tried to…
Kusti
  • 1,279
  • 1
  • 10
  • 18
90
votes
2 answers

What are the differences between add_axes and add_subplot?

In a previous answer it was recommended to me to use add_subplot instead of add_axes to show axes correctly, but searching the documentation I couldn't understand when and why I should use either one of these functions. Can anyone explain the…
Ivan
  • 1,069
  • 1
  • 9
  • 14
89
votes
1 answer

How to use matplotlib tight layout with Figure?

I found tight_layout function for pyplot and want to use it. In my application I embed matplotlib plots into Qt GUI and use figure and not pyplot. Is there any way I can apply tight_layout there? Would it also work if I have several axes in one…
Ekaterina Mishina
  • 1,633
  • 5
  • 20
  • 23
85
votes
6 answers

How to prevent numbers being changed to exponential form in a plot

I'm using Matplotlib in Python to plot simple x-y datasets. This produces nice-looking graphs, although when I "zoom in" too close on various sections of the plotted graph using the Figure View (which appears when you execute plt.show() ), the…
IanRoberts
  • 2,846
  • 5
  • 26
  • 33
78
votes
2 answers

How to save a figure remotely with pylab?

I'm trying to generate a figure at a remote computer with the command pylab.savefig. But I got such error: Unable to access the X Display, is $DISPLAY set properly? How can I save the figure properly?
gerry
  • 1,539
  • 1
  • 12
  • 22
77
votes
3 answers

How to get matplotlib figure size

For a project, I need to know the current size (in pixels) of my matplotlib figure, but I can't find how to do this. Does anyone know how to do this ?
Tristan
  • 793
  • 1
  • 5
  • 5
64
votes
4 answers

Adding subplots to a subplot

I'm trying to create a figure that consists of a 2x2 grid, where in each quadrant there are 2 vertically stacked subplots (i.e. a 2x1 grid). I can't seem to figure out how to achieve this, though. The closest I've gotten is using gridspec and some…
dan_g
  • 2,712
  • 5
  • 25
  • 44
1
2 3
99 100