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 8859597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:06:26+00:00 2026-06-14T15:06:26+00:00

I am looking for a way to rotate a plot generated in matplotlib-pyplot (Python

  • 0

I am looking for a way to rotate a plot generated in matplotlib-pyplot (Python libraries) by 45 degrees (so that instead of a square shape you would have a diamond shape, for example), anyone know if this can be done?

One way I can think of is to use a rotation filter on all the data so that it appears rotated, but then the plot itself will still be in the original orientation.

I want to be able to use the matplotlib interactive features, so saving as an image and then rotating won’t work.

Also, I want to use pyplot functions to draw the plot, so using a different library for the plotting is not an ideal solution.

  • 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-06-14T15:06:27+00:00Added an answer on June 14, 2026 at 3:06 pm

    Ok so currently the only partial solution I found is to apply a rotation to the plot. This allows to use the interactive interface that matplotlib/pyplot offers.

    For dot plots like plot() and scatter() this is trivial, but I was specifically interested in rotating imshow(). This link discusses the transform keyword that could have potentially been used for this task, but it is apparently not working.

    Fortunately, I found a workaround using pcolormesh(). pcolormesh() plots a quadrilateral mesh and allows you to specify the corner coordinates. So, the answer is to just apply the relevant transformations to the corner coordinates. Note however, that pcolormesh() works a bit different than imshow – it plots your matrix flipped.

    I haven’t seen this solution anywhere on the web, so here is some code for pcolormesh()/imshow() rotated by 45 degrees:

    import matplotlib.pyplot as plt
    import numpy as np
    
    def pcolormesh_45deg(C):
    
        n = C.shape[0]
        # create rotation/scaling matrix
        t = np.array([[1,0.5],[-1,0.5]])
        # create coordinate matrix and transform it
        A = np.dot(np.array([(i[1],i[0]) for i in itertools.product(range(n,-1,-1),range(0,n+1,1))]),t)
        # plot
        plt.pcolormesh(A[:,1].reshape(n+1,n+1),A[:,0].reshape(n+1,n+1),np.flipud(C))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there a way to rotate a PDF 90 degrees losslessly , with Python
I'm looking for a way to rotate a string in c++. I spend all
I'm looking for a way to rotate a string to the left N times.
Im looking for an easy way to move around a character and rotate it
My problem is that I was looking for way to use both storyboard and
I've just noticed that something terrible is missing in jquery-ui. A way to rotate
I'm looking for a way to implement gestures for zoom, pan and rotate in
All, I'm looking for a way to center and rotate an image in response
So I've been looking around for a way to rotate my background image, Probably
I'm looking for a way of decoding a bitmap from file rotated (0,90,180,270 degrees).

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.