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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:12:49+00:00 2026-05-18T02:12:49+00:00

Snippet: ax = Axes3D(self.fig) u = np.linspace(0, 2 * np.pi, 100) v = np.linspace(0,

  • 0

Snippet:

ax = Axes3D(self.fig)

u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)

x = self.prop * np.outer(np.cos(u), np.sin(v))
y = self.prop * np.outer(np.sin(u), np.sin(v))
z = self.prop * np.outer(np.ones(np.size(u)), np.cos(v))

t = ax.plot_surface(x, y, z, rstride=6, cstride=6,color='lightgreen',linewidth=0)
self.canvas.draw()

The above snippet graphs a sphere in tkinter using matplotlib. I’ve found that higher rstride and cstride values allow the graph to have a bit better performance. However, they give the sphere a weird ribbed shape. I was wondering what other things could be adjusted in the above code to help improve performance.

  • 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-18T02:12:49+00:00Added an answer on May 18, 2026 at 2:12 am

    Really, the problem is more within plot_surface. There are a lot of things that can be done to improve it. For instance, the shading takes a lot of time and just by changing one line:

    colors = [color * (0.5 + norm(v) * 0.5) for v in shade]
    

    to

    colors = np.outer(0.5+norm(shade)*0.5,color)
    

    within one of the functions used by plot_surface, I got a reduction of about 28% in the overall runtime. Why? The norm function (well, class kind of) is set-up for vectorization, but wasn’t being used in that manner. I know that there are many such things within these functions that aren’t very optimal. Changing the two lines:

    for rs in np.arange(0, rows-1, rstride):
        for cs in np.arange(0, cols-1, cstride):
    

    to

    for rs in xrange(0,rows-1,rstride):
        for cs in xrange(0,cols-1,cstride):
    

    in the plot_surface function itself gives another substantial improvement – now we’re down 33% from the original runtime.

    From what I’ve seen, the code isn’t really written for efficiency so much as to just get it working from what I can tell – there are plenty of places where things which could be made to be more vectorized using Numpy and aren’t. I’m afraid that what really is needed is some optimization of the matplotlib functions.

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

Sidebar

Related Questions

This snippet of Perl code in my program is giving the wrong result. $condition
This snippet works well if I try to write in a user directory but
code snippet: //byte[] myByteArray = byte array from database (database BLOB) myByteArray = (byte[])
The snippet says it all :-) UTF8Encoding enc = new UTF8Encoding(true/*include Byte Order Mark*/);
The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128.
In the following snippet: public class a { public void otherMethod(){} public void doStuff(String
I have a code snippet written in PHP that pulls a block of text
Here is a snippet of CSS that I need explained: #section { width: 860px;
Take the following snippet: List<int> distances = new List<int>(); Was the redundancy intended by
The following snippet of C# code: int i = 1; string result = String.Format({0},{1},{2},

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.