figure

Knitr ignoring fig.pos?

孤街醉人 提交于 2019-11-28 20:38:44
I am trying to insert a figure in a RMarkdown document but am having trouble getting it to appear in the right place. The figure below shows the problem: when using a figure caption, the figure appears at the top of the page rather than below the relevant paragraph in the document. Here is the code for this minimum working example: --- title: "Untitled" author: "Author" date: "27 February 2017" output: pdf_document: fig_cap: yes keep_tex: yes --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE, fig.pos= "h") ``` ## R Markdown This is an R Markdown document. Markdown is a simple

How to save a figure in MATLAB from the command line?

ぐ巨炮叔叔 提交于 2019-11-28 17:48:26
Is there a command in MATLAB which allows saving a figure in FIG or JPEG or both formats automatically? Use saveas : h=figure; plot(x,y,'-bs','Linewidth',1.4,'Markersize',10); % ... saveas(h,name,'fig') saveas(h,name,'jpg') This way, the figure is plotted, and automatically saved to '.jpg' and '.fig'. You don't need to wait for the plot to appear and click 'save as' in the menu. Way to go if you need to plot/save a lot of figures. If you really do not want to let the plot appear (it has to be loaded anyway, can't avoid that, else there is also nothing to save), you can hide it: h=figure(

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

一笑奈何 提交于 2019-11-28 17:16:07
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 reused from time to time...but I have no "deep(er) knowledge" of matplotlib . Recently I thought I should change this and work myself through some tutorials. However, I am still confused about matplotlibs plt , fig(ure) and ax(arr) . What is really the difference? In most cases, for some "quick'n'dirty' plotting I see people using just pyplot as plt and

How to create a new figure in MATLAB?

橙三吉。 提交于 2019-11-28 16:58:55
问题 Usually when I plot in MATLAB, it always draws on the same figure. How do I make it draw in a new figure? I know it is pretty elementary, but I'm not finding it using Google Search. 回答1: figure; plot(something); or figure(2); plot(something); ... figure(3); plot(something else); ... etc. 回答2: While doing "figure(1), figure(2),..." will solve the problem in most cases, it will not solve them in all cases. Suppose you have a bunch of MATLAB figures on your desktop and how many you have open

How to use matplotlib tight layout with Figure?

↘锁芯ラ 提交于 2019-11-28 16:21:42
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 figure? Just call fig.tight_layout() as you normally would. ( pyplot is just a convenience wrapper. In most cases, you only use it to quickly generate figure and axes objects and then call their methods directly.) There shouldn't be a difference between the QtAgg backend and the default backend (or if there is, it's a bug). E.g. import matplotlib.pyplot

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

喜欢而已 提交于 2019-11-28 15:13:06
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 converting my markdown to pdf, images get placed in one or two pages after and the document doesn't make any sense. UPDATE: I've tried Ryan's answer in that post and I can't make it working. Apparently the code : [image]: image.png "Image Title" ![Alt text][image] A reference to the [image](#image). should produce: \begin{figure}[htbp] \centering

python check if figure is 2d or 3d

对着背影说爱祢 提交于 2019-11-28 11:12:00
问题 In matlab with a figure, to check if it is 3D figure or 2D figure I use: V=axis; and check the number of components of V (4 for 2d figure, 6 for 3d figure). How can i implement this with python and matplotlib? 回答1: You can use the name of the axes. plt.gca().name or ax.name if ax is the axes. A 3D axes' name will be "3d" . A 2D axes' name will be "rectilinear" , "polar" or some other name depending on the type of plot. You can therefore check if ax.name == "3d": # axes is 3D, do something

How to combine several matplotlib figures into one figure?

独自空忆成欢 提交于 2019-11-28 07:31:17
问题 I have several matplotlib Figure-objects that I want to combine to one large figure by placing them next to another. How to get them into one figure? How to make them the same height? Note that I cannot change the way the individual figures are created. I can just use the resulting Figure objects. 回答1: It seems there is no (reliable - see bottom) matplotlib way of doing this, so one is stuck with using image processing tools on the figure-output. I'm using PNGs and PIL for that. Another

Matplotlib - adding subplots to a subplot?

我的梦境 提交于 2019-11-28 07:27:51
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 ugly code (see below), but because gridspec.update(hspace=X) changes the spacing for all of the subplots I'm still not where I'd like to be. Ideally what I want is to, using the picture below as an example, decrease the spacing between the subplots within each quadrant, while increasing the vertical spacing between the top and bottom quadrants (i.e.

How to superimpose figures in matplotlib

强颜欢笑 提交于 2019-11-28 05:44:06
问题 I create several figures in multiple modules, and i would like to superimpose them in my main.py . Can i return a usable figure/plot that could be reused in main.py to create a combined figure? Thanks! 回答1: The solution is to setup a figure/axis in main.py and then pass the axis handle to each module. As a minimal example, import matplotlib.pyplot as plt import numpy as np #from mod import plotsomefunction #from diffrentmod import plotsomeotherfunction def plotsomefunction(ax, x): return ax