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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:45:13+00:00 2026-05-31T00:45:13+00:00

From my basic understanding about using matplotlib you store your desired plt in some

  • 0

From my basic understanding about using matplotlib you store your desired plt in some ‘fig’ and then you can draw said ‘fig’ using the canvas.draw() operation. If this is the case then I shouldn’t have any problems but since I do, what exactly is going on and what’s the logic behind getting something on the canvas. Also, my end goal is to display this plot within a QtPy window. The results so far are that I can get the window and canvas to show but the canvas shows up empty. I have been looking at http://matplotlib.sourceforge.net/users/artists.html and feel like what I’m doing isn’t entirely wrong, but perhaps I’m overlooking some nuance. Here is the code I’m referencing:

def drawThis(self):

        self.axes.clear()
        self.axes.grid(self.grid_cb.isChecked())
        self.fig = plt.figure(figsize=(11,7),dpi=self.dpi)
        file = fileList[selFile]
        valid = [sColumn]
        matrix = np.loadtxt(file, skiprows=1, usecols=valid)
        colCount = np.loadtxt(file, dtype=object)
        totalCols = colCount.shape[1]

        kdeData = np.array(matrix)
        dataRange = (Decimal(max(abs(kdeData))) / 10).quantize(1, rounding=ROUND_UP) * 10

        gkde = stats.gaussian_kde(kdeData)
        ind = np.linspace(-int(dataRange), int(dataRange), len(kdeData) * sSamples)
        kdepdf = gkde.evaluate(ind)

        ##plot histogram of sample
        plt.hist(kdeData, len(kdeData), normed=1, alpha=0.20)
        ##plot data generating density
        plt.plot(ind, stats.norm.pdf(ind), 'r', linewidth=0.8, label='DGP normal')
        ##plot estimated density
        plt.plot(ind, kdepdf, 'g', linewidth=0.8, label='kde')
        plt.title('KDE for '+ str(nameList[selFile]))
        plt.legend()

        self.fig.canvas.draw()
  • 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-31T00:45:14+00:00Added an answer on May 31, 2026 at 12:45 am

    I don’t have any experience with matplotlib, but in looking at your code, I wonder if your use of pyplot is correct? The way your code looks to me, is that you are using pyplot to generate data (which you dont keep the return values of), and then you plot it, yet I think its not actually operating on your axis instance.

    An example of how I have seen matplotlib being used can be found here: Segfault using matplotlib with PyQt .. where he is actually directly creating a PyQt4 FigureCanvas and plotting directly to his axis instance.

    It seems that the pyplot.plot() method can take a figure and axis parameter to tell it which instance to use. I wonder if its not using your axis, since I can’t see in your example how you create the axis itself. Take at look at the docs here

    My guess is you might try doing something like this:

    plt.plot(ind, kdepdf, 'g', axis=self.axis, linewidth=0.8, label='kde')
    

    Or, maybe confirm that you have createe self.axis by using self.axis = plt.axis(), or even try doing all your plotting directly with the axis instance?

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

Sidebar

Related Questions

I'm receiving feedback from a developer that The only way visual basic (6) can
Trying to get some basic understanding of console functionalities. I am having issues so
I have only a basic understanding of Eclipse RCP. I am about to start
I've been doing some simple web programming using python, and I have a basic
I have a question about some code I'm testing to start understanding posix threads.
I'm making some fairly basic shapes in OpenGL-ES based on sample code from Apple.
My question is : from basic which are the necessary jars that should required
How does Digest Authentication differ from Basic Authentication other than sending credentials as plain
I created a site template from a basic site which was itself created from
This is very basic question from programming point of view but as I am

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.