Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 681271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:27:55+00:00 2026-05-14T01:27:55+00:00

I am using matplotlib and numpy to make a polar plot. Here is some

  • 0

I am using matplotlib and numpy to make a polar plot. Here is some sample code:

import numpy as N
import matplotlib.pyplot as P

angle = N.arange(0, 360, 10, dtype=float) * N.pi / 180.0
arbitrary_data = N.abs(N.sin(angle)) + 0.1 * (N.random.random_sample(size=angle.shape) - 0.5)

P.clf()
P.polar(angle, arbitrary_data)
P.show()

You will notice that 0° is at 3 o’clock on the plot, and the angles go counterclockwise. It would be more useful for my data visualization purposes to have 0° at 12 o’clock and have the angles go clockwise. Is there any way to do this besides rotating the data and manually changing the axis labels?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:27:55+00:00Added an answer on May 14, 2026 at 1:27 am

    I found it out — matplotlib allows you to create custom projections. I created one that inherits from PolarAxes.

    import numpy as np
    import matplotlib.pyplot as plt
    
    from matplotlib.projections import PolarAxes, register_projection
    from matplotlib.transforms import Affine2D, Bbox, IdentityTransform
    
    class NorthPolarAxes(PolarAxes):
        '''
        A variant of PolarAxes where theta starts pointing north and 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)
                theta = np.arctan2(y, x)
                return np.concatenate((theta, r), 1)
    
            def inverted(self):
                return NorthPolarAxes.NorthPolarTransform()
    
            def _set_lim_and_transforms(self):
                PolarAxes._set_lim_and_transforms(self)
                self.transProjection = self.NorthPolarTransform()
                self.transData = (self.transScale + self.transProjection + (self.transProjectionAffine + self.transAxes))
                self._xaxis_transform = (self.transProjection + self.PolarAffine(IdentityTransform(), Bbox.unit()) + self.transAxes)
                self._xaxis_text1_transform = (self._theta_label1_position + self._xaxis_transform)
                self._yaxis_transform = (Affine2D().scale(np.pi * 2.0, 1.0) + self.transData)
                self._yaxis_text1_transform = (self._r_label1_position + Affine2D().scale(1.0 / 360.0, 1.0) + self._yaxis_transform)
    
    register_projection(NorthPolarAxes)
    
    angle = np.arange(0, 360, 10, dtype=float) * np.pi / 180.0
    arbitrary_data = (np.abs(np.sin(angle)) + 0.1 * 
        (np.random.random_sample(size=angle.shape) - 0.5))
    
    plt.clf()
    plt.subplot(1, 1, 1, projection='northpolar')
    plt.plot(angle, arbitrary_data)
    plt.show()
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 434k
  • Answers 434k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer According to the Apache docs, it doesn't seem to be… May 15, 2026 at 3:07 pm
  • Editorial Team
    Editorial Team added an answer Having read the Ars Technica overview, it appears there are… May 15, 2026 at 3:07 pm
  • Editorial Team
    Editorial Team added an answer Try it like this: HttpContext.Current.Session("person_name") May 15, 2026 at 3:07 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.