figure

matplotlib: Stretch image to cover the whole figure

元气小坏坏 提交于 2021-02-18 22:53:58
问题 I am quite used to working with matlab and now trying to make the shift matplotlib and numpy. Is there a way in matplotlib that an image you are plotting occupies the whole figure window. import numpy as np import matplotlib.pyplot as plt # get image im as nparray # ........ plt.figure() plt.imshow(im) plt.set_cmap('hot') plt.savefig("frame.png") I want the image to maintain its aspect ratio and scale to the size of the figure ... so when I do savefig it exactly the same size as the input

Set matplotlib default figure window title

℡╲_俬逩灬. 提交于 2021-02-08 23:42:30
问题 The default window title of a figure is figure X, where X is increased each figure. I know how to change the title of a figure: fig = pylab.gcf() fig.canvas.set_window_title('Test') But how do I change the default window title (So that it will be Test 1, Test 2 etc..)? so that I will not need to change the window title each time. I did not find a key in the mpl.rcParams Thanks 回答1: When creating a figure using matplotlib.pyplot.subplots , there is an optional argument num that, even if not

Set matplotlib default figure window title

℡╲_俬逩灬. 提交于 2021-02-08 23:37:57
问题 The default window title of a figure is figure X, where X is increased each figure. I know how to change the title of a figure: fig = pylab.gcf() fig.canvas.set_window_title('Test') But how do I change the default window title (So that it will be Test 1, Test 2 etc..)? so that I will not need to change the window title each time. I did not find a key in the mpl.rcParams Thanks 回答1: When creating a figure using matplotlib.pyplot.subplots , there is an optional argument num that, even if not

Using pos option in chemnum changes the size of some labels

自闭症网瘾萝莉.ら 提交于 2021-01-29 10:30:24
问题 I am using pos options to change the alignment of chemnum tags. However, it changes the size of the labels. It appears to negate the defined font size in the preamble. What options am I missing? MWE eps file: https://drive.google.com/file/d/1ePJGhcUoorYQgAN_DR0A89RZFwWnIGtm/view?usp=sharing MWE code: \documentclass[12pt]{report} \usepackage[crop=off]{auto-pst-pdf} \usepackage{chemstyle} \usepackage{chemnum} \usepackage{ifpdf} \ifpdf \usepackage{tikz} \fi \setchemnum{ replace-style = \fontsize

Adding a figure created in a function to another figure's subplot

做~自己de王妃 提交于 2021-01-29 08:27:29
问题 I created two functions that make two specific plots and returns me the respective figures: import matplotlib.pyplot as plt x = range(1,100) y = range(1,100) def my_plot_1(x,y): fig = plt.plot(x,y) return fig def my_plot_2(x,y): fig = plt.plot(x,y) return fig Now, outside of my functions, I want to create a figure with two subplots and add my function figures to it. Something like this: my_fig_1 = my_plot_1(x,y) my_fig_2 = my_plot_2(x,y) fig, fig_axes = plt.subplots(ncols=2, nrows=1) fig_axes

How to format figcaption to not stretch a min-width figure

◇◆丶佛笑我妖孽 提交于 2021-01-29 03:10:57
问题 I use the following markup to present an image and its caption. HTML: <div class="fig-container"> <figure class="captioned-figure"> <img class="full-width" src="..."/> <figcaption> TEXT TEXT TEXT </figcaption> </figure> </div> CSS: .fig-container{ text-align: center; } .captioned-figure{ display: inline-block; min-width: 50%; } .full-width{ display: block; width: 100%; height: auto; } My goal is to have the image horizontally centered and scaled to at least 50% of the viewport, but to no more

rotating the z-axis in matplotlib 3d figure

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-28 20:18:55
问题 How do I rotate the z-axis of a matplotlib figure so that it appears as the horizontal axis? I have created the following 3d figure : I tried adjusting the values in ax.view_init() but no matter what values I used, I can't flip the z-axis so that the orientation of the three axes appear as like the ones in the following figure: I thought of changing the three components of all the data so that I use the x-axis to plot the z-component of the data, but then it will be very inconvenient to many

How do I change the axes' units in a figure?

£可爱£侵袭症+ 提交于 2021-01-28 09:37:42
问题 I'm making figures of some galaxies velocities with matplotlib , from some .fits files. The problem is that the axes in the figure show the galaxy's size in pixels, and I want to display them as Declination and RightAcension (in angle units). I already know that each pixel has a size of 0.396 arcseconds. How can I convert pixels to arcseconds in both X and Y axes? The code is the folowing: ############################################################################## # Generally the image

matplotlib: get the subplot layout?

天涯浪子 提交于 2021-01-28 02:58:15
问题 I have a function that creates a grid of similar 2D histograms. So that I can select whether to put this new plot on a pre-existing figure, I do the following: def make_hist2d(x, y, current_fig=False, layout=(1,1,1),*args): if current_fig: fig = _plt.gcf() ax = fig.add_subplot(*layout) # layout=(nrows, ncols, nplot) else: fig, ax = _plt.subplots() H, x, y = np.histogram2d(...) # manipulate the histogram, e.g. column normalize. XX, YY = _np.meshgrid(xedges, yedges) Image = ax.pcolormesh(XX, YY

MATLAB figures don't have the same size when inserted in LaTeX (Although produced using the same code)

徘徊边缘 提交于 2021-01-27 14:11:38
问题 I am producing some figures in MATLAB and try to insert them in LaTeX. However, when I do so, they usually don't have the same size (although I am using the same setup to produce them). For example: The MATLAB code I am currently using is this one lsize = 16; % Label fontsize nsize = 16; % Axis fontsize q=randn(100,1000); a1=linspace(1,1000,1000); b1=linspace(2,2000,1000); figure (1) histogram(q) xlabel('Time [sec]','Fontsize', lsize) ylabel('W_{kin} [keV]','Fontsize', lsize) set(gca,