python - Zoom to rectangle on polar plot -


i have polar scatter plot. unable 'zoom' in on data points manipulating x , y axis limits, due nature of polar projection.

how 'zoom rectangle', specifying coordinates of rectangle corners, example? plot shown below.

image of plot.

example code:

import numpy np #from matplotlib.path import path  import matplotlib.pyplot plt import matplotlib.cbook cbook   mpl_toolkits.axisartist.grid_helper_curvelinear import gridhelpercurvelinear mpl_toolkits.axisartist import subplot  mpl_toolkits.axisartist import subplothost, \      parasiteaxesauxtrans  import  mpl_toolkits.axisartist.angle_helper angle_helper matplotlib.projections import polaraxes matplotlib.transforms import affine2d  def polarasrect(fig):      mpl_toolkits.axisartist.grid_helper_curvelinear import gridhelpercurvelinear     mpl_toolkits.axisartist import subplot      mpl_toolkits.axisartist import subplothost, \      parasiteaxesauxtrans      import  mpl_toolkits.axisartist.angle_helper angle_helper     matplotlib.projections import polaraxes     matplotlib.transforms import affine2d     """     polar projection, in rectangular box.     """      # polaraxes.polartransform takes radian. however, want our coordinate     # system in degree     tr = affine2d().translate(-135,0) + affine2d().scale(np.pi/180., 1.) + polaraxes.polartransform()      # polar projection, involves cycle, , has limits in     # coordinates, needs special method find extremes     # (min, max of coordinate within view).      # 20, 20 : number of sampling points along x, y direction     extreme_finder = angle_helper.extremefindercycle(20, 20,                                                      lon_cycle = 360,                                                      lat_cycle = none,                                                      lon_minmax = none,                                                      lat_minmax = (0, np.inf),                                                      )      grid_locator1 = angle_helper.locatordms(12)     # find grid values appropriate coordinate (degree,     # minute, second).      tick_formatter1 = angle_helper.formatterdms()     # , uses appropriate formatter.  note that,the     # acceptable locator , formatter class bit different     # of mpl's, , cannot directly use mpl's locator ,     # formatter here (but may possible in future).      grid_helper = gridhelpercurvelinear(tr,                                         extreme_finder=extreme_finder,                                         grid_locator1=grid_locator1,                                         tick_formatter1=tick_formatter1                                         )       ax1 = subplothost(fig, 1, 1, 1, grid_helper=grid_helper)      # make ticklabels of right , top axis visible.     ax1.axis["right"].major_ticklabels.set_visible(true)     ax1.axis["top"].major_ticklabels.set_visible(false)      # let right axis shows ticklabels 1st coordinate (angle)     ax1.axis["right"].get_helper().nth_coord_ticks=0     # let bottom axis shows ticklabels 2nd coordinate (radius)     ax1.axis["bottom"].get_helper().nth_coord_ticks=1      fig.add_subplot(ax1)       # parasite axes given transform     ax2 = parasiteaxesauxtrans(ax1, tr, "equal")     # note ax2.transdata == tr + ax1.transdata     # anthing draw in ax2 match ticks , grids of ax1.     ax1.parasites.append(ax2)      ax1.set_aspect(1)     ax1.set_xlim(0, 1)     ax1.set_ylim(-1, 1)       ax1.grid(true)     return ax1, ax2  if 1:     fig = plt.figure()     fig.clf()      ax, aux_ax = polarasrect(fig)     z,ra = np.random.rand(200000), 360*np.random.rand(200000)     #z = [0.11693845,0.09111419,0.09107255,0.09114332,0.09113075,0.09117671,0.09107338,0.10745689,0.09192869,0.08961995]     #ra = [2.34269333,2.26779991,2.26750563,2.26784652,2.26796822,2.26747208, 2.26755943,2.2657325, 2.26631627,2.34835654]     aux_ax.scatter(ra,z,c='r',s=1.0,linewidths=0.0)     plt.draw()     plt.show()     '''from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes     axins = zoomed_inset_axes(ax, 2.5, loc=2) # zoom-factor: 2.5, location: upper-left     axins.scatter(ra,z,c='r',s=10.0,linewidths=0.0)     plt.show()''' 


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -