figure

How do you get the current figure number in Python's matplotlib?

How do you get the current figure number in Python's matplotlib? Question: I’m playing around with an example script that shows how to switch back and forth between figures. I found the example here: http://matplotlib.org/examples/pylab_examples/multiple_figs_demo.html When I try to print out the figure number I get “Figure(640×480)” instead of the number 1 I was expecting. …

Total answers: 1

How to make more than 10 subplots in a figure?

How to make more than 10 subplots in a figure? Question: I am trying to make a 5×4 grid of subplots, and from looking at examples it seems to me that the best way is: import matplotlib.pyplot as plt plt.figure() plt.subplot(221) where the first two numbers in the subplot (22) indicate that it is a …

Total answers: 1

Understanding matplotlib: plt, figure, ax(arr)?

Understanding matplotlib: plt, figure, ax(arr)? Question: I’m not really new to matplotlib and I’m deeply ashamed to admit I have always used it as a tool for getting a solution as quick and easy as possible. So I know how to get basic plots, subplots and stuff and have quite a few code which gets …

Total answers: 3

Matplotlib – adding subplots to a subplot?

Matplotlib – adding subplots to a subplot? Question: I’m trying to create a figure that consists of a 2×2 grid, where in each quadrant there are 2 vertically stacked subplots (i.e. a 2×1 grid). I can’t seem to figure out how to achieve this, though. The closest I’ve gotten is using gridspec and some ugly …

Total answers: 4

How to get matplotlib figure size

How to get matplotlib figure size Question: 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 ? Asked By: Tristan || Source Answers: import matplotlib.plt fig = plt.figure() size = fig.get_size_inches()*fig.dpi # size …

Total answers: 3

How to prevent numbers being changed to exponential form in Python matplotlib figure

How to prevent numbers being changed to exponential form in a plot Question: 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 x-axis values …

Total answers: 6

Python Matplotlib figure title overlaps axes label when using twiny

Python Matplotlib figure title overlaps axes label when using twiny Question: 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’, xy=(Planet.T_day*1.3,(Planet.R)/1000), xytext=(Planet.T_day*1.3, Planet.R/1000)) ax.annotate(‘Geostat. orbit’, xy=(Planet.T_day*1.3, r_geo[0]), xytext=(Planet.T_day*1.3, r_geo[0])) …

Total answers: 7

Matplotlib different size subplots

Matplotlib different size subplots Question: 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 …

Total answers: 6

How to use matplotlib tight layout with Figure?

How to use matplotlib tight layout with Figure? Question: 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 …

Total answers: 1

Matplotlib (pyplot) savefig outputs blank image

Matplotlib (pyplot) savefig outputs blank image Question: 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, y) plt.imshow(dataStack, cmap=mpl.cm.bone) plt.imshow(y, cmap=mpl.cm.jet_r, interpolation=’nearest’) if T0 is not None: plt.subplot(123) plt.imshow(T0, cmap=mpl.cm.bone) #plt.subplot(124) #Autozoom …

Total answers: 5