matplotlib-users

 [Matplotlib-users] contour plot in semi-circle domain From: Kenshi hibino - 2010-09-13 15:09:36 ```Hi! I want to use polar plot and write contour in semi-circle domain.But I can't do so. Here is a part of my code. ----------------------------- from pylab import * from scipy import * fig=figure(figsize=(10,10)) ax=fig.add_axes([0.1,0.1,0.8,0.8],polar=True) axis([0, pi, 0, 1]) show() ---------------------------- I thought that "axis([0,pi,0,1])" make the writing domain semi-circle, but complete circle was written as domain. Does anyone know how I should write? Many thanks, Kenshi -- View this message in context: http://old.nabble.com/contour-plot-in-semi-circle-domain-tp29699332p29699332.html Sent from the matplotlib - users mailing list archive at Nabble.com. ```
 Re: [Matplotlib-users] contour plot in semi-circle domain From: Jae-Joon Lee - 2010-09-14 00:11:55 ```On Tue, Sep 14, 2010 at 12:09 AM, Kenshi hibino wrote: > I thought that "axis([0,pi,0,1])" make the writing domain semi-circle, > but complete circle was written as domain. > > Does anyone know how I should write? > With "polar" projection, it is not possible to make semi-circle domain. You need to make a custom projection (http://matplotlib.sourceforge.net/devel/add_new_projection.html). But it would not be easy for a normal user. Another option is to use mpl_toolkits.axisartist (distributed with mpl 1.0). However, learning curve of the axisartist is also steep. You may play around with the last figure in the example below. http://matplotlib.sourceforge.net/examples/axes_grid/demo_floating_axes.html Regards, -JJ ```
 Re: [Matplotlib-users] contour plot in semi-circle domain From: Kenshi hibino - 2010-09-17 10:34:27 ``` Jae-Joon Lee wrote: > > > Another option is to use mpl_toolkits.axisartist (distributed with mpl > 1.0). However, learning curve of the axisartist is also steep. You may > play around with the last figure in the example below. > > http://matplotlib.sourceforge.net/examples/axes_grid/demo_floating_axes.html > > Jae-Joon, Thanks for the quick reply and good advice. Second option you recommended is seemed to work well. My code modified from example is attached. But, in semi-circle domain I can't write contour label using clabel(). Do you know the reason why? http://old.nabble.com/file/p29737063/test2.py test2.py For reference my system is python(x,y) on Windows and mpl version is 1.0 Thanks again. Kenshi -- View this message in context: http://old.nabble.com/contour-plot-in-semi-circle-domain-tp29699332p29737063.html Sent from the matplotlib - users mailing list archive at Nabble.com. ```
 Re: [Matplotlib-users] contour plot in semi-circle domain From: Jae-Joon Lee - 2010-10-22 12:53:05 Attachments: tererer.py ```Kenshi, I'm sorry that I completely forgot about this issue. I just took a look and it seems to be due to a bug in clabel routine. The fix is easy and I'll commit it soon. Meanwhile, here is a work around. Basically, you need to draw a contour in "ax3", not in "aux_ax3". First of all, you can populate Z without for loops (note that I changed X, Y to Theta, R). Theta, R = meshgrid(theta, r) Z = (Theta/90.)**2 + (R-2)**2 Now, instead of aux_ax3.contour, use CS = aux_contour(aux_ax3, Theta, R, Z,levels,colors='k') where aux_contour is defined as def aux_contour(aux_ax, aux_X, aux_Y, Z, *kl, **kwargs): ax = aux_ax._parent_axes shape_orig = Theta.shape TR = np.array([aux_X, aux_Y]).reshape((2, -1)).transpose() # coordinates in aux_ax XY = aux_ax.transAux.transform(TR) # coordinates in ax X, Y = XY.transpose().reshape((2, shape_orig[0], shape_orig[1])) CS = ax.contour(X, Y, Z, *kl, **kwargs) return CS And do clabel with the original axes (ax3). use_clabeltext will help the labels aligned with contour lines. ax3.clabel(CS,fontsize=10, use_clabeltext=True) A complete example is attached. Regards, -JJ On Fri, Sep 17, 2010 at 7:34 PM, Kenshi hibino wrote: > > > Jae-Joon Lee wrote: >> >> >> Another option is to use mpl_toolkits.axisartist (distributed with mpl >> 1.0). However, learning curve of the axisartist is also steep. You may >> play around with the last figure in the example below. >> >> http://matplotlib.sourceforge.net/examples/axes_grid/demo_floating_axes.html >> >> > > Jae-Joon, > Thanks for the quick reply and good advice. > > Second option you recommended is seemed to work well. > My code modified from example is attached. > > But, in semi-circle domain I can't write contour label using clabel(). > Do you know the reason why? http://old.nabble.com/file/p29737063/test2.py > test2.py > > For reference my system is python(x,y) on Windows and mpl version is 1.0 > > Thanks again. > > Kenshi > -- > View this message in context: http://old.nabble.com/contour-plot-in-semi-circle-domain-tp29699332p29737063.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing. > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ```