figure

How to change the order of lines in a Matlab figure?

懵懂的女人 提交于 2019-11-27 12:03:48
问题 Given a plot of three curves in a .fig file I'd like to add another plot (with hold all and plot ), but put it behind one of the already existing curves (i.e. make sure the last original curve stays the foreground one). Can this be achieved without having to extract the plot data and re-plotting? 回答1: If you know the handle of line you want on top (e.g. because you called h = plot(...) , you can use uistack uistack(h,'top') Alternatively, you can manipulate the order of children of your

Knitr ignoring fig.pos?

跟風遠走 提交于 2019-11-27 11:40:22
问题 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

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

送分小仙女□ 提交于 2019-11-27 09:51:30
问题 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

How to use matplotlib tight layout with Figure?

拟墨画扇 提交于 2019-11-27 09:36:29
问题 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? 回答1: 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

What are the differences between add_axes and add_subplot?

允我心安 提交于 2019-11-27 09:19:24
问题 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 differences? 回答1: Common grounds Both, add_axes and add_subplot add an axes to a figure. They both return a (subclass of a) matplotlib.axes.Axes object. However, the mechanism which is used to add the axes differs substantially. add_axes The calling

How can I rotate a matplotlib plot through 90 degrees?

北城余情 提交于 2019-11-27 09:14:08
I have created a figure in matplotlib which contains three subplots, one in the top left quadrant, one in the top right quadrant, and one in the bottom right quadrant. The top right figure contains a two-d image, and the other two plots are the projection onto the Y and X axis respectively. I'd like to rotate the top left quadrant subplot through 90deg counterclockwise, so that the x-axis of that plot lies along the y-axis of the 2-d plot. For the subplot, I realize I could flip the x and y data, rotate the axis labels, create a plot title on the left hand side, etc. But I was hoping to find a

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

孤街浪徒 提交于 2019-11-27 06:06:24
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 how to fix it. Here is my code: par(mfcol=c(5,3)) hist(RtBio, main="Histograma de Bio Pappel") boxplot(RtBio, main="Diagrama de Caja de Bio Pappel") stem(RtBio) plot(RtBio, main="Gráfica de Dispersión") hist(RtAlsea, main="Histograma de Alsea") boxplot(Alsea, main="Diagrama de caja de Alsea") stem(RtAlsea) plot(RtTelev, main="Gráfica de distribución

How to plot a circle in Matlab?

試著忘記壹切 提交于 2019-11-27 05:22:29
I would like to know how can I graph circles in matlab knowing the center and radius? I have tried circles() which does not seem to work because my matlab version does not have it. I know I can use the Rectangle function to do so but it is a rather complex way of doing it as I would need to work out the leftmost point everytime. Isnt there a more simple way for me to draw a circle JUST knowing center and radius? many thanks Don't laugh, but the easiest would be to use the rectangle function, indeed ;) %// radius r = 2; %// center c = [3 3]; pos = [c-r 2*r 2*r]; rectangle('Position',pos,

How to import local image using knitr for markdown

*爱你&永不变心* 提交于 2019-11-27 04:21:49
问题 I have an externally created png image in a local directory that I'd like to import to a report using knitr. The ultimate target filetype is html. I have no trouble getting my own figures to appear when I create them with R code, but I'm at a loss what I would have thought was a simpler problem. While I'm at it, how would I import a figure for which I have a url? 回答1: If you already have a local image, you can just use the HTML or markdown syntax to include it in your document. HTML syntax is

matplotlib savefig in jpeg format

泪湿孤枕 提交于 2019-11-27 01:41:26
I am using matplotlib (within pylab) to display figures. And I want to save them in .jpg format. When I simply use the savefig command with jpg extension this returns : ValueError: Format "jpg" is not supported. Supported formats: emf, eps, pdf, png, ps, raw, rgba, svg, svgz. Is there a way to perform this ? Yann You can save an image as 'png' and use the python imaging library (PIL) to convert this file to 'jpg': import Image import matplotlib.pyplot as plt plt.plot(range(10)) plt.savefig('testplot.png') Image.open('testplot.png').save('testplot.jpg','JPEG') The original: The JPEG image: To