[Matplotlib-users] graphs removing gaps to left and right,

2008-11-06 Thread oliver marks
hi,

I have successfully written my first test program in matlab, it works
perfectly except the display is not quite right, to the left and write
of the plotted data there are blank areas with nothing on, how can i get
rid of these a link to the image is attached, and the code is below.

hope someone can tell me what i am doing wrong.

http://imagebin.ca/view/dYSphQ.html

import dateutil
import datetime


class graph:
def __init__(self):
pass

def data(self):
pass

def line_graph(self,path):
return "matplotlib not installed, graph not displayed."

def bar_graph(self,path):
return "matplotlib not installed, graph not displayed."

try:
import matplotlib
matplotlib.use("agg")
import numpy as np
import matplotlib.pyplot as plt
import pylab
from matplotlib.dates import MonthLocator, WeekdayLocator 

class graph:
def __init__(self):
self.xaxis=[]
self.yaxis=[]
self.values=[]
self.fig=pylab.figure() 

def data(self,data):
self.values=data

def labels(self):
pass
def xaxis_dates(self,dates,format="%d/%m/%Y"):
dtlist=[datetime.datetime.strptime(s, format) for s in
dates]
self.xaxis=pylab.date2num(dtlist)
ax = self.fig.add_subplot(111) 
days= WeekdayLocator()   # every year
months   = MonthLocator()  # every month
ax.xaxis.set_major_locator(months)
#ax.xaxis.set_minor_locator(days)

def line_graph(self):
plt.plot_date(self.xaxis,self.values,visible=True,
linestyle='-')

def bar_graph(self):
plt.bar(self.xaxis,self.values)
#plt.bar(self.xaxis,self.values,label=r)

def make(self,fname):
plt.savefig(fname)
htmout=""
return htmout

#matplotlib not installed rather than fall over create a dummy class, as
we do not want to rely on graphing,
#non essential feature
except ImportError, e:
class graph:
def __init__(self):
self.xaxis=[]
self.yaxis=[]
self.data=[]

def data(self,data):
pass

def line_graph(self,path):
return "matplotlib not installed, graph not displayed."

def bar_graph(self,path):
return "matplotlib not installed, graph not displayed."

def make(self):
plt.plot_date(da,d,visible=True, linestyle='-')
plt.savefig("graph.png")


dates=['01/10/2008', '02/10/2008', '03/10/2008', '04/10/2008',
'05/10/2008', '06/10/2008', '07/10/2008', '08/10/2008', '09/10/2008',
'10/10/2008', '11/10/2008', '12/10/2008', '13/10/2008', '14/10/2008',
'15/10/2008', '16/10/2008', '17/10/2008', '18/10/2008', '19/10/2008',
'20/10/2008', '21/10/2008', '22/10/2008', '23/10/2008', '24/10/2008',
'25/10/2008', '26/10/2008', '27/10/2008', '28/10/2008', '29/10/2008']
data=(73, 76, 58, 0, 0, 105, 138, 98, 64, 42, 0, 0, 100, 115, 97, 69,
153, 1, 0, 84, 122, 131, 77, 97, 0, 0, 117, 99, 101)

g=graph()
g.xaxis_dates(dates)
g.data(data)
g.line_graph()
g.make("test.png")

g=graph()
g.xaxis_dates(dates)
g.data(data)
g.bar_graph()
g.make("testbar.png")
#dates=[datetime.datetime.strptime(s, "%d/%m/%Y") for s in r]
#print r
#print dates
#d=(73, 76, 58, 0, 0, 105, 138, 98, 64, 42, 0, 0, 100, 115, 97, 69, 153,
1, 0, 84, 122, 131, 77, 97, 0, 0, 117, 99, 101)
#d=(100,150)
#days= MonthLocator()   # every year
#months   = MonthLocator()  # every month
#yearsFmt = DateFormatter('%Y')

#fig = pylab.figure() 
#ax = fig.add_subplot(111) 

#labels = ax.get_xticklabels()
#pylab.setp(labels,'rotation','vertical')

#days= MonthLocator()   # every year
#months   = MonthLocator()  # every month
#ax.xaxis.set_major_locator(months)
#ax.xaxis.set_major_formatter(yearsFmt)
#ax.xaxis.set_minor_locator(days)


#da=pylab.date2num(dates)
#plt.plot_date(da,d,visible=True, linestyle='-')
#plt.bar(da,d,label=r)
#plt.savefig("graph.png")


CONFIDENTIALITY NOTICE:
The information contained in this communication is confidential and may be 
legally privileged. It is intended solely for the use of the individual(s) to 
whom it is addressed and others authorised to receive it. If you are not the 
intended recipient you are hereby notified that any disclosure, copying, 
distribution or action taken in relation to the contents of this information is 
strictly prohibited and may be unlawful. Neither the sender nor HoMedics Group 
Ltd is liable for the correct and complete transmission of the contents of an 
email, or for its timely receipt. If you receive this communication in error, 
please destroy it and notify HoMedics Group Ltd immediately on +44 (0)1732 
354828. Company No. 4353765, Registered Address: HoMedics House, Somerhill 
Business Park, Five Oak Green

[Matplotlib-users] matplotlib cairo backend

2009-01-29 Thread Oliver Marks
are there any tutorials / examples / documentation on the use of the
cairo backend i am currently using gtk and want to work with cairo for
printing.

I have looked around and not found much information on this backend.


signature.asc
Description: This is a digitally signed message part
--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users