Python: clockwise polar plot -


how can make clockwise plot? ask similar question here: how make angles in matplotlib polar plot go clockwise 0° @ top?
dont understand this.

import matplotlib.pyplot plt import numpy np  fig = plt.figure() ax = fig.add_subplot(111, polar=true) ax.grid(true)  theta = np.arange(0,370,10) theta = [i*np.pi/180.0 in theta]  # convert radians  x = [3.00001,3,3,3,3,3,3,3,3,3,3,3,3,3,2.5,2,2,2,2,2,1.5,1.5,1,1.5,2,2,2.5,2.5,3,3,3,3,3,3,3,3,3] ax.plot(theta, x) plt.show() 

edit:

import matplotlib.pyplot plt import numpy np matplotlib.projections import polaraxes, register_projection matplotlib.transforms import affine2d, bbox, identitytransform  class northpolaraxes(polaraxes):     '''     variant of polaraxes theta starts pointing north , goes     clockwise.     '''     name = 'northpolar'      class northpolartransform(polaraxes.polartransform):         def transform(self, tr):             xy   = np.zeros(tr.shape, np.float_)             t    = tr[:, 0:1]             r    = tr[:, 1:2]             x    = xy[:, 0:1]             y    = xy[:, 1:2]             x[:] = r * np.sin(t)             y[:] = r * np.cos(t)             return xy          transform_non_affine = transform          def inverted(self):             return northpolaraxes.invertednorthpolartransform()      class invertednorthpolartransform(polaraxes.invertedpolartransform):         def transform(self, xy):             x = xy[:, 0:1]             y = xy[:, 1:]             r = np.sqrt(x*x + y*y)  fig = plt.figure() register_projection(northpolaraxes) ax=plt.subplot(1, 1, 1, projection='northpolar')     theta=np.linspace(0,2*np.pi,37) x = [3.00001,3,3,3,3,3,3,3,3,3,3,3,3,3,2.5,2,2,2,2,      2,1.5,1.5,1,1.5,2,2,2.5,2.5,3,3,3,3,3,3,3,3,3] ax.plot(theta, x) plt.show() 

how correctly using register_projection(northpolaraxes) ?

add these strings:

ax.set_theta_direction(-1)  ax.set_theta_offset(pi/2.0) 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -