figure

Matplotlib, shift boxplots along x-axis?

被刻印的时光 ゝ 提交于 2019-12-11 09:27:32
问题 I am plotting multiple boxplots along two different axes. My code looks like: fig, (ax1, ax2) = plt.subplots(2, sharex=True, sharey=False) data_1 = [array1, array2, array3] ax1.boxplot(data_1, whis=[5,95], showfliers=True) data_2 = [array4, array5] ax2.boxplot(data_2, whis=[5,95], showfliers=True) ax2.set_xlim(0,4) This produces a plot (substituting in my actual data) that looks like: However, I would like the lower plot (on ax2) to shift to the right along the x-axis by one unit. That is, I

Enable white frames on matplotlib figure/ Disable transparent frames

↘锁芯ラ 提交于 2019-12-11 06:34:30
问题 I'm running ipython notebook on a dark theme. When I build a chart on this, the chart is white, but the frame is transparent (hence dark), hiding the ticks which are also dark. Is there a way to make the frame not transparent/ white? The ticks are barely visible due to black background. How do I solve this? Thanks! Edit: This is not about changing the colors of axis, ticks/labels, I'm thinking of adding a white background frame, not changing the colors of ticks - it'll be ugly if I just

how to change the sequence of the legend

大兔子大兔子 提交于 2019-12-11 03:13:59
问题 I want to change the sequence of the legend. See the figure. I want the sequence to be: green and data2 , blue and data3 , black and data4 , red and data1 . Could anyone give a demo? 回答1: Change the order in which the plots are added to the figure, and then call legend normally. That should do it. You can also do it as follows. First get handles to the individual plots: h1 = plot(1:5); hold on h2 = plot(11:15, 'r'); Then call legend specifying the order: legend([h1 h2],'plot1','plot2') or

matplotlib issues when nan first in list

主宰稳场 提交于 2019-12-10 22:17:32
问题 I have two lists of numbers which I'm using matplotlib to graph in Python. However if one of the lists begins with the value of nan, matplotlib will not graph any of the 15k+ points I have. However if there is a nan value somewhere in the list after the first value, it simply skips it and graphs the other points fine. I'm curious how to work around this without changing the first nan value. 回答1: you can use the numpy.isnan function to mask your list: a=np.array([np.nan,1,2,3,4,np.nan]) mask=

Matlab: How to change the linewidth in a figure before actually plotting some?

流过昼夜 提交于 2019-12-10 18:34:33
问题 This question maybe a bit like the link below, but this didn't work for me... http://nl.mathworks.com/matlabcentral/answers/102530-how-can-i-change-the-default-settings-for-the-linewidth-property-before-i-plot-a-figure-in-matlab I'm working on a matlab function that automatically opens your figure in full screen mode and on a second monitor if present. So far, everything works fine. I already achieved to set the fontsize inside the function, so whitout plotting anything and without making

How to reset matplotlib animation without re-running script

ⅰ亾dé卋堺 提交于 2019-12-10 16:52:30
问题 I'm using matplotlib's FuncAnimation function to animate a segment of a large dataset: fig = plt.figure(figsize=(15, 11.5)) ax = fig.add_subplot(111, aspect='equal', autoscale_on=False, xlim=(x1,x2), ylim=(y1, y2)) data,=ax.plot([],[],'o') def init(): data.set_data([],[]) return data def animate(t): global x_pos,y_pos data.set_data(x_pos[t],y_pos[t]) return data ani=animation.FuncAnimation(fig,animate,frames=duration,interval=20, init_func=init,blit=True) plt.show() When I run my code from

Obtaining the figure manager via the OO interface in Matplotlib

寵の児 提交于 2019-12-10 15:44:34
问题 I want to be able to get the figure_manager of a created figure: e.g. I can do it with the pyplot interface using: from pylab import* figure() plot(arange(100)) mngr = get_current_fig_manager() However what if I have a few figures: from pylab import * fig0 = figure() fig1 = figure() plot(arange(100)) mngr = fig0.get_manager() #DOES NOT WORK - no such method as Figure.get_manager() however, searching carefully through the figure API, http://matplotlib.org/api/figure_api.html, was not useful.

How to get shaded background in xyplot in R?

守給你的承諾、 提交于 2019-12-10 15:11:49
问题 using xyplot from the lattice package, I plot a time series over a number of years. I would to add a shaded area for some of these years to indicate that this time period was "special" (e.g. war). Please apologize if this is trivial, but I could not figure out how to do that, so I would be happy if someone could help me out, or at least point me in the right direction. I think my main problem is that I don't really know how to approach this problem. I am still relatively new to R, and to

Nonfloating figure spanning two columns in multicol environment

允我心安 提交于 2019-12-10 14:49:33
问题 I am using the multicol package, with two columns, and need a figure to span both columns. I am aware of \begin{figure*} , but I do not want the figure to float. I have been googling for about an hour, to no avail. Any help would be great. 回答1: Have a look at the package nonfloat (it is part of TeXlive so there is a good chance you already have it). The following example taken from the manual of nonfloat shows how you can have a non-floating figure with caption: \begin{minipage}{\linewidth}

Adjusting figure margins in Rmarkdown

穿精又带淫゛_ 提交于 2019-12-10 13:54:27
问题 I am trying to adjust the piechart figure in my Rmarkdown document so that it spans the width of the page or at least becomes wide enough to fit all of the labels. I have tried everything - adjusting figure.height and figure.width , margins with par(mar) and par(oma) , but nothing seems to work. Either the pies themselves become smaller, or the labels are even more cut off. I would like the pies to be as large as possible with clearly visible labels, but every time it renders small pies and