figures

knitr: include figures in report *and* output figures to separate files

柔情痞子 提交于 2019-11-27 02:20:07
问题 Not only would I like my figures to appear in my knitr-generated report, but I would also like to output them to separate files, too. To do this, I have included code like the following: ```{r} #Plot figure in report plot(x,y) #Plot figure in file pdf(file="MyFig.pdf") plot(x,y) dev.off() ``` This works fine, but I expect there's a more elegant solution for this already built into knitr. Is there a chunk option or something similar that achieves the same results? 回答1: Use the option self

prevent plot from showing in jupyter notebook

允我心安 提交于 2019-11-27 00:51:06
问题 How can I prevent a specific plot to be shown in Jupyter notebook? I have several plots in a notebook but I want a subset of them to be saved to a file and not shown on the notebook as this slows considerably. A minimal working example for a Jupyter notebook is: %matplotlib inline from numpy.random import randn from matplotlib.pyplot import plot, figure a=randn(3) b=randn(3) for i in range(10): fig=figure() plot(b) fname='s%03d.png'%i fig.savefig(fname) if(i%5==0): figure() plot(a) As you can

How do I get the handles of all open figures in MATLAB

怎甘沉沦 提交于 2019-11-26 12:03:35
问题 I have nine open figures in matlab (generated by another function) and I want to print them all to file. Does anyone know how to grab the handles of all open figures in MATLAB? I know about gcf but it doesn\'t seem to do what I want. 回答1: There are a few ways to do this. One way to do this is to get all the children of the root object (represented in prior versions by the handle 0 ): figHandles = get(groot, 'Children'); % Since version R2014b figHandles = get(0, 'Children'); % Earlier