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

  • SEARCH
  • Home
  • 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 6121811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:49:35+00:00 2026-05-23T15:49:35+00:00

i have the following code: import psycopg2 import pylab class Datenanzeige: def __init__(self): self.conn

  • 0

i have the following code:

import psycopg2
import pylab


class Datenanzeige:

def __init__(self):
    self.conn = psycopg2.connect("dbname='test' user='test' host='test' password='test'")
    self.cur = self.conn.cursor()

    self.site = ['FFF', 'PPP', 'DDD', 'KKK']
    self.plant = [1, 2, 3, 4, 5, 6]


def anzeige(self):

    for i in range(4):
        for j in range(6):

            self.datProd1 = []
            self.datProd2 = []

            self.cur.execute(""" 
                    SELECT proddate, Sum(mods) AS Summevonmods 
                    FROM "20091229global" 
                    GROUP BY proddate, site, plant, pid 
                    HAVING proddate > Date('today') - 14
                    AND
                    site='"""+self.site[i]+"""'
                    AND
                    pid=802
                    AND
                    plant='"""+str(self.plant[j])+"""' 
                    ORDER BY proddate, site, plant, pid; 
                    """)

            self.row = self.cur.fetchone()

            while self.row:
                self.datProd1.append(self.row[0])
                self.datProd2.append(self.row[1])

                pylab.title('Progress of %s' %self.site[i])
                pylab.ylabel('number')
                pylab.xlabel('date')
                pylab.plot(self.datProd1, self.datProd2)
                pylab.savefig("bild%i" %i )

                self.row=self.cur.fetchone()

q = Datenanzeige()
q.anzeige()

the code is working. i get for every self.site variable another picture but every following picture includes the lines of the former one. how can i prevent this?
i need separate pictures without lines of the former one.

  • 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-23T15:49:36+00:00Added an answer on May 23, 2026 at 3:49 pm

    To do what you want, you need do one of two things:

    1. use the clf() and cla() (clear figure and clear axes respectively) methods after you’ve saved your figures.

    2. Create multiple figures, and then set the title and axes label on each figure. At the moment, you’re using a default background figure that pylab gives you. You need to explicitly create and modify different ones. I can’t write the exact code of the top of my head to do that, but a look at the matplotlib api should give you what you are looking for. It will look something like this:

      import matplotlib.pyplot as plt
      
      fig = plt.figure()
      axes = fig.add_subplot(1,1,1)
      axes.set_xlabel("foo")
      axes.set_ylabel("bar")
      axes.set_title("title")
      # ...
      fig.savefig("filename")
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Java code: import java.util.Arrays; import java.util.Collections; public class Test {
i have the following code in a module called code_database.py class Entry(): def enter_data(self):
Say I have the following code: import java.lang.InterruptedException; import javax.swing.SwingWorker; public class Test {
I have the following simple Java code: package testj; import java.util.*; public class Query<T>
I have following code in Java: import java.util.*; public class longest{ public static void
I have the following code in Django: import locale locale.setlocale( locale.LC_ALL, '' ) def
I have the following code: import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.util.Locale; public final class
If I have the following code: import sqlite sqlite.connect('tmp.db').cursor().close() I get the following error
I have the following code: trait A { import org.somepackage.C._ } class B extends
Please have a look at following code : import java.util.ArrayList; import java.util.List; class Main{

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.