Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After successfully saved a png picture, you can not use it #3913

Closed
wangzili opened this issue Dec 12, 2014 · 4 comments
Closed

After successfully saved a png picture, you can not use it #3913

wangzili opened this issue Dec 12, 2014 · 4 comments
Labels
status: needs clarification Issues that need more information to resolve.

Comments

@wangzili
Copy link

for example:

def create_pie():
        figure(1,figsize=(6,6),facecolor=(0,0,0))   
        ax = axes([0.1, 0.1, 0.8, 0.8])
        fracs = self.data 
        labels = '1','2','3','4','5','6'

        explode=(0,0,0,0,0,0)    
        patches, texts = pie(fracs, explode=explode, labels=labels, shadow=True) 
        savefig('pie.png',facecolor=(0,0,0))

If you call create_pie() in other places, it will show Resource "pie.png" was not found on the path

create_pie()
pyglet.resource.image('pie.png')

[TAC edited for markup]

@tacaswell tacaswell added this to the unassigned milestone Dec 12, 2014
@tacaswell tacaswell added the status: needs clarification Issues that need more information to resolve. label Dec 12, 2014
@tacaswell
Copy link
Member

This sounds more like this is a pyglet issue than an mpl issue. If you open the png some other route does it look correct?

What do you think the bug in matplotlib is?

@wangzili
Copy link
Author

I 'm very sorry for my fault, it is pyglet a issue ,sorry!!!

@wangzili
Copy link
Author

I have a new problem.When the operation is repeated for a picture, the picture will continue to change, but the last time label not disappear,can you tell me the reason?
paste my code:
#encoding:utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

import time
import json
import urllib2
from random import randint as ra
from pylab import *

class Pie(object):
def init(self, data, date_time=None):
self.data = data
self.date_time = date_time
self.create_pie()

def create_pie(self):
    figure(1,figsize=(6,6),facecolor=(0,0,0))  
    ax = axes([0.1, 0.1, 0.8, 0.8])
    fracs = self.data
    labels = 'hello','world','you','are','lucky','boy'

    explode=(0,0,0,0,0,0)   
    #patches, texts, autotexts = pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True)  
    patches, texts = pie(fracs, explode=explode, labels=labels, shadow=True)        
    for i in texts:
        i.set_color('w')
    title('Raining Hogs and Dogs'.encode('utf-8'), bbox={'facecolor':'0.8', 'pad':5})
    savefig('pie.png',facecolor=(0,0,0))

def make_png(date_time=None):
m = ra(10, 50)
n = 60-m
data = ['10', '10', '10', '10', m, n]
print data
Pie(data)

if name == "main":
while 1:
make_png()
time.sleep(1)

@WeatherGod
Copy link
Member

Your axes() constructor is simply overlaying a new axes on top of any
existing axes from previous runs. If you use subplots(111), then it should
only create it once. Subsequent calls will fetch the already created axes.

You will also see previous plots as well. You may want to call
"hold(False)" as well.

Ben Root
On Dec 15, 2014 5:23 AM, "王自力" notifications@github.com wrote:

I have a new problem.When the operation is repeated for a picture, the
picture will continue to change, but the last time label not disappear,can
you tell me the reason?
paste my code:
#encoding:utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

import time
import json
import urllib2
from random import randint as ra
from pylab import *

class Pie(object):

def init(self, data, date_time=None):
self.data = data
self.date_time = date_time
self.create_pie()

def create_pie(self):
figure(1,figsize=(6,6),facecolor=(0,0,0))
ax = axes([0.1, 0.1, 0.8, 0.8])
fracs = self.data
labels = 'hello','world','you','are','lucky','boy'

explode=(0,0,0,0,0,0)
#patches, texts, autotexts = pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True)
patches, texts = pie(fracs, explode=explode, labels=labels, shadow=True)
for i in texts:
    i.set_color('w')
title('Raining Hogs and Dogs'.encode('utf-8'), bbox={'facecolor':'0.8', 'pad':5})
savefig('pie.png',facecolor=(0,0,0))

def make_png(date_time=None):
m = ra(10, 50)
n = 60-m
data = ['10', '10', '10', '10', m, n]
print data
Pie(data)

if name == "main":
while 1:
make_png()
time.sleep(1)


Reply to this email directly or view it on GitHub
#3913 (comment)
.

@efiring efiring closed this as completed Feb 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs clarification Issues that need more information to resolve.
Projects
None yet
Development

No branches or pull requests

4 participants