You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(33) |
Dec
(20) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(7) |
Feb
(44) |
Mar
(51) |
Apr
(43) |
May
(43) |
Jun
(36) |
Jul
(61) |
Aug
(44) |
Sep
(25) |
Oct
(82) |
Nov
(97) |
Dec
(47) |
| 2005 |
Jan
(77) |
Feb
(143) |
Mar
(42) |
Apr
(31) |
May
(93) |
Jun
(93) |
Jul
(35) |
Aug
(78) |
Sep
(56) |
Oct
(44) |
Nov
(72) |
Dec
(75) |
| 2006 |
Jan
(116) |
Feb
(99) |
Mar
(181) |
Apr
(171) |
May
(112) |
Jun
(86) |
Jul
(91) |
Aug
(111) |
Sep
(77) |
Oct
(72) |
Nov
(57) |
Dec
(51) |
| 2007 |
Jan
(64) |
Feb
(116) |
Mar
(70) |
Apr
(74) |
May
(53) |
Jun
(40) |
Jul
(519) |
Aug
(151) |
Sep
(132) |
Oct
(74) |
Nov
(282) |
Dec
(190) |
| 2008 |
Jan
(141) |
Feb
(67) |
Mar
(69) |
Apr
(96) |
May
(227) |
Jun
(404) |
Jul
(399) |
Aug
(96) |
Sep
(120) |
Oct
(205) |
Nov
(126) |
Dec
(261) |
| 2009 |
Jan
(136) |
Feb
(136) |
Mar
(119) |
Apr
(124) |
May
(155) |
Jun
(98) |
Jul
(136) |
Aug
(292) |
Sep
(174) |
Oct
(126) |
Nov
(126) |
Dec
(79) |
| 2010 |
Jan
(109) |
Feb
(83) |
Mar
(139) |
Apr
(91) |
May
(79) |
Jun
(164) |
Jul
(184) |
Aug
(146) |
Sep
(163) |
Oct
(128) |
Nov
(70) |
Dec
(73) |
| 2011 |
Jan
(235) |
Feb
(165) |
Mar
(147) |
Apr
(86) |
May
(74) |
Jun
(118) |
Jul
(65) |
Aug
(75) |
Sep
(162) |
Oct
(94) |
Nov
(48) |
Dec
(44) |
| 2012 |
Jan
(49) |
Feb
(40) |
Mar
(88) |
Apr
(35) |
May
(52) |
Jun
(69) |
Jul
(90) |
Aug
(123) |
Sep
(112) |
Oct
(120) |
Nov
(105) |
Dec
(116) |
| 2013 |
Jan
(76) |
Feb
(26) |
Mar
(78) |
Apr
(43) |
May
(61) |
Jun
(53) |
Jul
(147) |
Aug
(85) |
Sep
(83) |
Oct
(122) |
Nov
(18) |
Dec
(27) |
| 2014 |
Jan
(58) |
Feb
(25) |
Mar
(49) |
Apr
(17) |
May
(29) |
Jun
(39) |
Jul
(53) |
Aug
(52) |
Sep
(35) |
Oct
(47) |
Nov
(110) |
Dec
(27) |
| 2015 |
Jan
(50) |
Feb
(93) |
Mar
(96) |
Apr
(30) |
May
(55) |
Jun
(83) |
Jul
(44) |
Aug
(8) |
Sep
(5) |
Oct
|
Nov
(1) |
Dec
(1) |
| 2016 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(3) |
Sep
(1) |
Oct
(3) |
Nov
|
Dec
|
| 2017 |
Jan
|
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
(7) |
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Ted D. <ted...@jp...> - 2005-07-22 20:41:55
|
The legend() docs state:
Make a legend with existing lines
>>> legend()
legend by itself will try and build a legend using the label
property of the lines/patches/collections. You can set the label of
a line by doing plot(x, y, label='my data') or line.set_label('my
data'). If label is set to '_nolegend_', the item will not be shown
in legend.
But trying to pass '_nolegend_' doesn't seem to work. And a grep through
the code finds no instances of '_nolegend_'.
import pylab as p
x = p.arange( 0,3, .1 )
y1 = p.cos( x )
y2 = p.sin( x )
y3 = 2*p.sin( x )
p.plot( x, y1 )
p.plot( x, y2 )
p.plot( x, y3 )
p.legend( ( "cos(x)", "_nolegend_", "2*sin(x)" ) )
p.show()
|
|
From: Maria K. <mar...@ut...> - 2005-07-21 16:00:08
|
Hi,
I was creating a legend with the location variable being set to 'best'. However
when my graph contained only one point, the matplotlib code produced an error. I
found that the branch that handles the "one point case" passes the arguments to
the bbox.contains call incorrectly. I am using cvs version of the library.
The following is the patch for the problem: (Note that I edited the installed file)
--- legend.py 2005-05-20 12:18:34.000000000 -0400
+++ /usr/lib/python2.4/site-packages/matplotlib/legend.py 2005-07-21
11:25:08.576508496 -0400
@@ -51,7 +51,7 @@
return False
if n == 1:
- return bbox.contains(line[0])
+ return bbox.contains(line[0][0], line[0][1])
p1 = line[0]
for p2 in line[1:]:
Best regards,
Maria Khomenko
|
|
From: Nicholas Y. <su...@su...> - 2005-07-20 13:26:56
|
Hi, In my work I've come across a need to plot arrows with a position specified in data coordinates but which appear in the rendered plot with a constant size and shape, independent of zoom or aspect ratio (as opposed to the patch.Arrow class which acts like a vector image of an arrow and as such changes in rendered size on zooming or aspect ratio change). It appeared to me that the most obvious way to implement this was as a new arrowhead marker style for the lines.Line2D class (with no marker shown for the first point in the line). This should allow more general use than just as simple arrows; for example in plotting vectors. I've attached a patch to CVS to implement this as a marker accessed using the symbol 'a'. The marker is a triangle pointing in the correct direction for an an arrowhead and with its point at the end of the line segment. There are two main problems with the attached code. Firstly as the arrowhead is potentially pointing in a different direction for each point the renderer.draw_markers method can't be used and plotting will thus be slower. Secondly, for linewidth > 1 the line appears either side of the point of the arrowhead. I can see two potential ways around the second problem: moving the arrowhead forwards which is unsuitable for vectors or altering the length of lines plotted where the marker is an arrowhead which requires lots more code than it seemed sensible to add. Anyway, despite the problems noted I thought this code might be generally useful. Nick |
|
From: Robert K. <rk...@uc...> - 2005-07-15 02:22:25
|
Since this topic comes up every now and again, allow me to point out a resource I just happened upon: http://www.bitjungle.com/~isoent/ On this page is a link to an XML file that is a very thorough database mapping Unicode code points (at least, ones that we care about) to their LaTeX representation. When the LaTeX representation requires a particular package or environment, these are provided. For example: <char pos="840"> <entity name="Kcy" set="iso-8879-cyr1"> <desc>=capital KA, Cyrillic</desc> </entity> <unicode value="041A"> <desc>CYRILLIC CAPITAL LETTER KA</desc> </unicode> <latex> <seq req="cyracc,amsfonts" env="cyr">K</seq> <seq req="fontenc:T2A">\CYRK</seq> </latex> </char> This is the mapping to end all mappings. It evens comes with convenient PDF references. -- Robert Kern rk...@uc... "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter |
|
From: John H. <jdh...@ac...> - 2005-07-14 18:34:01
|
>>>>> "Jamil" == Jamil Khan <jam...@ca...> writes:
Jamil> Apparently the mailing list doesn't do attachments. So here
Jamil> is the source instead: - Jamil Khan
Hi Jamil -- thanks for contributing these. They look very snazzy --
nice design!
As they are they will be useful, but to make them maximally useful, I
think they should be refactored using the matplotlib API and not the
pylab interface, since gauges are typically used in GUI application
rather than one-off scripts and most application developers use the
API rather than pylab. It is a fairly easy migration -- I'll include
an example refactoring of gauge.py below. For more details on the
API, see
http://matplotlib.sourceforge.net/faq.html#OO
Are you interested in doing this? If we get these cleaned up a bit
and documented, they would be a nice start to a new "toolkit"
http://matplotlib.sourceforge.net/toolkits.html
Here is the modified gauge.py, which defines a Gauge as a custom
Axes. This can now be used from the pylab interface or the matplotlib
API. One other things to note: all of your setp calls could be
removed by simply passing the kwargs to the relevant function. Eg,
instead of
p = plot(x_vect, y_vect, 'b-')
setp(p, color='black')
setp(p, linewidth=1.5)
you could do
p = plot(x_vect, y_vect, 'b-')
setp(p, color='black',linewidth=1.5)
or event better
p = plot(x_vect, y_vect, 'b-', color='black',linewidth=1.5)
Another little trick; in several places you do things like
temp = limits[0]
limits[0] = limits[1]
limits[1] = temp
With the magic of tuples, you can avoid the temporary and do this in
one line
limits[0], limits[1] = limits[1] = limits[0]
Also, do you intend to do integer division in lines like
graph_width/2
If not, you will want to do one of 'from __future__ import division'
or graph_width/2.
For efficiency and to save typing, you may want to replace blocks like
x_vect = []
x_vect.append( (graph_width/2) )
x_vect.append( (graph_width/2) )
x_vect.append(-(graph_width/2) )
x_vect.append(-(graph_width/2) )
x_vect.append( (graph_width/2) )
with
x_vect = [
graph_width/2,
graph_width/2,
-graph_width/2,
-graph_width/2,
graph_width/2,
]
Final comment: your code uses tabs rather than spaces for indentation,
which can cause problems and is nonstandard. Perhaps you could
configure your editor to use spaces for indentation?
Thanks for the contribution!
JDH
Example refactoring of gauge.py
#!/usr/bin/env python
"""
The Gauge widget draws a semi-circular gauge. You supply limits,
shaded regions, names and the current value, and invoke it like this:
from pylab import figure, show
current_value = -4.0
limits = [-1.0,1.0,1,0.1]
zone_colour = [[-1.0,0.0,'r'],[0.0,0.5,'y'],[0.5,1.0,'g']]
attribute_name = "Rx MOS (24h)"
graph_height = 1.6
graph_width = 2.4
fig_height = graph_height
fig_width = graph_width
fig = figure(figsize=(fig_width, fig_height ))
rect = [(0.0/fig_width), (0.2/fig_height),
(graph_width/fig_width), (graph_height/fig_height)]
gauge = Gauge(fig, rect,
xlim=( -0.1, graph_width+0.1 ),
ylim=( -0.4, graph_height+0.1 ),
xticks=[],
yticks=[],
)
gauge.set_axis_off()
fig.add_axes(gauge)
show()
"""
from __future__ import division
from matplotlib.figure import Figure
from matplotlib.axes import Axes
import math
import types
from math import pi
class Gauge(Axes):
def __init__(self, *args, **kwargs):
Axes.__init__(self, *args, **kwargs)
#Perform Checking
if( limits[0] == limits[1] ):
raise ValueError('identical_limits_exception: %s'%limits)
if( limits[1] > limits[0] ):
graph_positive = True
else: #Swap the limits around
graph_positive = False
limits[0], limits[1] = limits[1] = limits[0]
#There must be an integer number of minor ticks for each major tick
if not( ((limits[2]/limits[3]) % 1.0) * limits[3] == 0 ):
raise ValueError('bad_tick_spacing_exception')
if( limits[2] <= 0 or
limits[3] <= 0 or
limits[2] < limits[3] or
limits[3] > abs(limits[1]-limits[0]) ):
raise ValueError('bad_limits_exception:%s' % limits)
for zone in zone_colour:
if( zone[0] > zone[1] ): #Swap the zones so zone[1] > zone[0]
zone[0], zone[1] = zone[1], zone[0]
if( zone[1] < limits[0] or zone[0] > limits[1] ):
raise ValueError('bad_zone_exception'%zone)
if( zone[0] < limits[0] ):
zone[0] = limits[0]
if( zone[1] > limits[1] ):
zone[1] = limits[1]
#Draw the arch
for zone in zone_colour:
self.draw_arch(limits, zone[0], zone[1], zone[2], False, graph_positive)
self.draw_arch(limits, limits[0], limits[1], 'black', True, graph_positive)
self.draw_ticks(limits, graph_positive)
self.draw_needle(current_value, limits, graph_positive)
self.draw_bounding_box(graph_width, graph_height)
self.text(0.0, 0.2, attribute_name, size=10, va='bottom', ha='center')
#The black dot.
p = self.plot([0.0],[0.0],'.', color='#000000')
def draw_arch(self, limits, start_angle, end_angle, colour, border, graph_positive):
x_vect = []
y_vect = []
if( graph_positive ):
start = int(180 - (start_angle - limits[0]) * (180.0/(limits[1]-limits[0])))
end = int(180 - (end_angle - limits[0]) * (180.0/(limits[1]-limits[0])))
else:
start = int( (end_angle - limits[0]) * (180.0/(limits[1]-limits[0])))
end = int( (start_angle - limits[0]) * (180.0/(limits[1]-limits[0])))
#Draw the arch
theta = start
radius = 0.85
while (theta >= end):
x_vect.append( radius * math.cos(theta * (pi/180)) )
y_vect.append( radius * math.sin(theta * (pi/180)) )
theta -= 1
theta = end
radius = 1.0
while (theta <= start):
x_vect.append( radius * math.cos(theta * (pi/180)) )
y_vect.append( radius * math.sin(theta * (pi/180)) )
theta += 1
if( border ):
#Close the loop
x_vect.append(-0.85)
y_vect.append(0.0)
p = self.plot(x_vect, y_vect, 'b-', color='black', linewidth=1.5)
else:
p = self.fill(x_vect, y_vect, colour, linewidth=0.0, alpha=0.4)
def draw_needle(self, current_value, limits, graph_positive):
x_vect = []
y_vect = []
if current_value == None:
self.text(0.0, 0.4, "N/A", size=10, va='bottom', ha='center')
else:
self.text(0.0, 0.4, "%.2f" % current_value, size=10, va='bottom', ha='center')
#Clamp the value to the limits
if( current_value < limits[0] ):
current_value = limits[0]
if( current_value > limits[1] ):
current_value = limits[1]
theta = 0
length = 0.95
if( graph_positive ):
angle = 180.0 - (current_value - limits[0]) *(180.0/abs(limits[1]-limits[0]))
else:
angle = (current_value - limits[0]) *(180.0/abs(limits[1]-limits[0]))
while (theta <= 270):
x_vect.append( length * math.cos((theta + angle) * (pi/180)) )
y_vect.append( length * math.sin((theta + angle) * (pi/180)) )
length = 0.05
theta += 90
p = self.fill(x_vect, y_vect, 'b', alpha=0.4)
def draw_ticks(self, limits, graph_positive):
if( graph_positive ):
angle = 180.0
else:
angle = 0.0
i = 0
j = limits[0]
while( i*limits[3] + limits[0] <= limits[1] ):
x_vect = []
y_vect = []
if( i % (limits[2]/limits[3]) == 0 ):
x_pos = 1.1 * math.cos( angle * (pi/180.0))
y_pos = 1.1 * math.sin( angle * (pi/180.0))
if( type(limits[2]) is types.FloatType ):
self.text( x_pos, y_pos, "%.2f" % j, size=10, va='center', ha='center', rotation=(angle - 90))
else:
self.text( x_pos, y_pos, "%d" % int(j), size=10, va='center', ha='center', rotation=(angle - 90))
tick_length = 0.15
j += limits[2]
else:
tick_length = 0.05
i += 1
x_vect.append( 1.0 * math.cos( angle * (pi/180.0)))
x_vect.append( (1.0 - tick_length) * math.cos( angle * (pi/180.0)))
y_vect.append( 1.0 * math.sin( angle * (pi/180.0)))
y_vect.append( (1.0 - tick_length) * math.sin( angle * (pi/180.0)))
p = self.plot(x_vect, y_vect, 'b-', linewidth=1, alpha=0.4, color="black")
if( graph_positive ):
angle -= limits[3] * (180.0/abs(limits[1]-limits[0]))
else:
angle += limits[3] * (180.0/abs(limits[1]-limits[0]))
if( i % (limits[2]/limits[3]) == 0 ):
x_pos = 1.1 * math.cos( angle * (pi/180.0))
y_pos = 1.1 * math.sin( angle * (pi/180.0))
if( type(limits[2]) is types.FloatType ):
self.text( x_pos, y_pos, "%.2f" % j, size=10, va='center', ha='center', rotation=(angle - 90))
else:
self.text( x_pos, y_pos, "%d" % int(j), size=10, va='center', ha='center', rotation=(angle - 90))
def draw_bounding_box(self, graph_width, graph_height):
x_vect = [
graph_width/2,
graph_width/2,
-graph_width/2,
-graph_width/2,
graph_width/2,
]
y_vect = [
-0.1,
graph_height,
graph_height,
-0.1,
-0.1,
]
p = self.plot(x_vect, y_vect, 'r-', linewidth=0)
if __name__=='__main__':
from pylab import figure, show
current_value = -4.0
limits = [-1.0,1.0,1,0.1]
zone_colour = [[-1.0,0.0,'r'],[0.0,0.5,'y'],[0.5,1.0,'g']]
attribute_name = "Rx MOS (24h)"
graph_height = 1.6
graph_width = 2.4
fig_height = graph_height
fig_width = graph_width
fig = figure(figsize=(fig_width, fig_height ))
rect = [(0.0/fig_width), (0.2/fig_height),
(graph_width/fig_width), (graph_height/fig_height)]
gauge = Gauge(fig, rect,
xlim=( -0.1, graph_width+0.1 ),
ylim=( -0.4, graph_height+0.1 ),
xticks=[],
yticks=[],
)
gauge.set_axis_off()
fig.add_axes(gauge)
show()
|
|
From: Jamil K. <jam...@ca...> - 2005-07-14 00:18:57
|
Apparently the mailing list doesn't do attachments. So here is the = source instead: - Jamil Khan Design Engineer, Calyptech Pty. Ltd. www.calyptech.com =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= linear rotary gauge =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= #!/usr/bin/env python # # This program draws a semi-circular gauge. You supply limits, # shaded regions, names and the current value, and invoke=20 # it like this: # # draw_widget( current_value,=20 # limits[ lower, upper, major ticks, minor ticks], # shaded zones [ [lower,upper,colour], # [lower,upper,colour], # ...],=20 # name "MOS",=20 # filename "gauge_0.png", # resolution in dpi # ) # # from pylab import * #from matplotlib.patches import Patch, Rectangle, Circle, Polygon, = Wedge, Shadow, bbox_artist import math import types import matplotlib matplotlib.use('Agg') # force the antigrain backend from matplotlib.backends.backend_agg import FigureCanvasAgg def draw_arch(limits, start_angle, end_angle, colour, border, = graph_positive): x_vect =3D [] y_vect =3D [] if( graph_positive ): start =3D int(180 - (start_angle - limits[0]) * = (180.0/(limits[1]-limits[0]))) end =3D int(180 - (end_angle - limits[0]) * = (180.0/(limits[1]-limits[0]))) else: start =3D int( (end_angle - limits[0]) * = (180.0/(limits[1]-limits[0]))) end =3D int( (start_angle - limits[0]) * = (180.0/(limits[1]-limits[0]))) =09 #Draw the arch theta =3D start radius =3D 0.85 while (theta >=3D end): x_vect.append( radius * math.cos(theta * (pi/180)) ) y_vect.append( radius * math.sin(theta * (pi/180)) ) theta -=3D 1 =09 theta =3D end radius =3D 1.0 while (theta <=3D start): x_vect.append( radius * math.cos(theta * (pi/180)) ) y_vect.append( radius * math.sin(theta * (pi/180)) ) theta +=3D 1 =09 if( border ): #Close the loop x_vect.append(-0.85) y_vect.append(0.0) =09 p =3D plot(x_vect, y_vect, 'b-') setp(p, color=3D'black') setp(p, linewidth=3D1.5) else: p =3D fill(x_vect, y_vect, colour) setp(p, linewidth=3D0.0) setp(p, alpha=3D0.4) =09 def draw_needle(current_value, limits, graph_positive): x_vect =3D [] y_vect =3D [] =09 if current_value =3D=3D None: text(0.0, 0.4, "N/A", size=3D10, va=3D'bottom', ha=3D'center') else: text(0.0, 0.4, "%.2f" % current_value, size=3D10, va=3D'bottom', = ha=3D'center') =09 #Clamp the value to the limits if( current_value < limits[0] ): current_value =3D limits[0] if( current_value > limits[1] ): current_value =3D limits[1] =09 theta =3D 0 length =3D 0.95 if( graph_positive ): angle =3D 180.0 - (current_value - limits[0]) = *(180.0/abs(limits[1]-limits[0])) else: angle =3D (current_value - limits[0]) = *(180.0/abs(limits[1]-limits[0])) =09 while (theta <=3D 270): x_vect.append( length * math.cos((theta + angle) * (pi/180)) ) y_vect.append( length * math.sin((theta + angle) * (pi/180)) ) length =3D 0.05 theta +=3D 90 =09 p =3D fill(x_vect, y_vect, 'b') setp(p, alpha=3D0.4) =09 =09 =09 def draw_ticks(limits, graph_positive): if( graph_positive ): angle =3D 180.0 else: angle =3D 0.0 i =3D 0 j =3D limits[0] =09 iterating =3D True while( i*limits[3] + limits[0] <=3D limits[1] ): x_vect =3D [] y_vect =3D [] if( i % (limits[2]/limits[3]) =3D=3D 0 ): x_pos =3D 1.1 * math.cos( angle * (pi/180.0)) y_pos =3D 1.1 * math.sin( angle * (pi/180.0)) if( type(limits[2]) is types.FloatType ): text( x_pos, y_pos, "%.2f" % j, size=3D10, va=3D'center', = ha=3D'center', rotation=3D(angle - 90))=20 else: text( x_pos, y_pos, "%d" % int(j), size=3D10, va=3D'center', = ha=3D'center', rotation=3D(angle - 90))=20 tick_length =3D 0.15 j +=3D limits[2] else: tick_length =3D 0.05 i +=3D 1 x_vect.append( 1.0 * math.cos( angle * (pi/180.0))) x_vect.append( (1.0 - tick_length) * math.cos( angle * (pi/180.0))) y_vect.append( 1.0 * math.sin( angle * (pi/180.0))) y_vect.append( (1.0 - tick_length) * math.sin( angle * (pi/180.0))) p =3D plot(x_vect, y_vect, 'b-') setp(p, linewidth=3D1) setp(p, alpha=3D0.4) setp(p, color=3D"black") if( graph_positive ): angle -=3D limits[3] * (180.0/abs(limits[1]-limits[0])) else: angle +=3D limits[3] * (180.0/abs(limits[1]-limits[0])) if( i % (limits[2]/limits[3]) =3D=3D 0 ): x_pos =3D 1.1 * math.cos( angle * (pi/180.0)) y_pos =3D 1.1 * math.sin( angle * (pi/180.0)) if( type(limits[2]) is types.FloatType ): text( x_pos, y_pos, "%.2f" % j, size=3D10, va=3D'center', = ha=3D'center', rotation=3D(angle - 90))=20 else: text( x_pos, y_pos, "%d" % int(j), size=3D10, va=3D'center', = ha=3D'center', rotation=3D(angle - 90)) =09 =09 =09 def draw_bounding_box(graph_width, graph_height): x_vect =3D [] y_vect =3D [] =09 x_vect.append( (graph_width/2) ) x_vect.append( (graph_width/2) ) x_vect.append(-(graph_width/2) ) x_vect.append(-(graph_width/2) ) x_vect.append( (graph_width/2) ) =09 y_vect.append(-0.1) y_vect.append(graph_height) y_vect.append(graph_height) y_vect.append(-0.1) y_vect.append(-0.1) =09 p =3D plot(x_vect, y_vect, 'r-') setp(p, linewidth=3D0) =09 =09 def draw_widget( current_value, limits, zone_colour, attribute_name, = filename, resolution=3D72 ): graph_height =3D 1.6 graph_width =3D 2.4 fig_height =3D graph_height fig_width =3D graph_width =09 figure(figsize=3D(fig_width, fig_height )) a =3D axes([(0.0/fig_width), (0.2/fig_height), (graph_width/fig_width), = (graph_height/fig_height)]) setp(a, xlim=3D( -0.1, graph_width+0.1 ), ylim=3D( -0.4, = graph_height+0.1 ), xticks=3D[], yticks=3D[]) axis('off') =09 #Perform Checking if( limits[0] =3D=3D limits[1] ): raise 'identical_limits_exception', limits if( limits[1] > limits[0] ): graph_positive =3D True else: #Swap the limits around graph_positive =3D False temp =3D limits[0] limits[0] =3D limits[1] limits[1] =3D temp =09 if not( ((limits[2]/limits[3]) % 1.0) * limits[3] =3D=3D 0 ): #There = must be an integer number of minor ticks for each major tick raise 'bad_tick_spacing_exception' if( limits[2] <=3D 0 or limits[3] <=3D 0 or limits[2] < limits[3] or = limits[3] > abs(limits[1]-limits[0]) ): raise 'bad_limits_exception', limits for zone in zone_colour: if( zone[0] > zone[1] ): #Swap the zones so zone[1] > zone[0] temp =3D zone[0] zone[0] =3D zone[1] zone[1] =3D temp if( zone[1] < limits[0] or zone[0] > limits[1] ): raise 'bad_zone_exception', zone if( zone[0] < limits[0] ): zone[0] =3D limits[0] if( zone[1] > limits[1] ): zone[1] =3D limits[1] =09 #Draw the arch for zone in zone_colour: draw_arch(limits, zone[0], zone[1], zone[2], False, graph_positive) draw_arch(limits, limits[0], limits[1], 'black', True, graph_positive) draw_ticks(limits, graph_positive) draw_needle(current_value, limits, graph_positive) draw_bounding_box(graph_width, graph_height) text(0.0, 0.2, attribute_name, size=3D10, va=3D'bottom', ha=3D'center') =09 #The black dot. p =3D plot([0.0],[0.0],'.') setp(p, color=3D'#000000') =09 savefig( filename, dpi=3Dresolution) #draw_widget( 21.0, [4.0,20.0,4,1.0], = [[4.0,10.0,'r'],[10.0,14.0,'y'],[14.0,20.0,'g']], "Rx MOS (24h)", = "gauge_0.png", 100) #draw_widget( -10.0, [-20.0,-4,4.0,1.0], = [[-4.0,-10.0,'r'],[-10.0,-14.0,'y'],[-14.0,-20.0,'g']], "Rx MOS (24h)", = "gauge_0.png", 100) #draw_widget( -10.5, [20.0,-20.0,4.0,1.0], = [[-20.0,-15.0,'r'],[-10.0,-15.0,'y'],[-10.0,20.0,'g']], "Rx MOS (24h)", = "gauge_0.png", 100) #draw_widget( None, [4.0,20.0,4,1.0], = [[4.0,10.0,'r'],[10.0,14.0,'y'],[14.0,20.0,'g']], "Rx MOS (24h)", = "gauge_0.png", 100) #draw_widget( 1.2, [4.0,10.0,2,0.5], = [[4.0,6.0,'r'],[6.0,8.0,'y'],[8.0,10.0,'g']], "Rx MOS (24h)", = "gauge_1.png", 100) draw_widget( -4.0, [-1.0,1.0,1,0.1], = [[-1.0,0.0,'r'],[0.0,0.5,'y'],[0.5,1.0,'g']], "Rx MOS (24h)", = "gauge_2.png", 100) #show() =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= linear horizontal gauge =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= #!/usr/bin/env python # # This program draws a horizontal linear meter. You supply limits, # shaded regions, names and the current value, and invoke=20 # it like this: # # draw_widget( current_value,=20 # limits[ lower, upper, major ticks, minor ticks], # shaded zones [ [lower,upper,colour], # [lower,upper,colour], # ...],=20 # name "MOS",=20 # filename "v_meter_0.png", # resolution in dpi # ) # # from pylab import * import types #from matplotlib.patches import Patch, Rectangle, Circle, Polygon, = Wedge, Shadow, bbox_artist #import math def draw_bar( graph_positive, graph_height, start, end, colour): x_vect =3D [] y_vect =3D [] =09 y_vect.append( 0.0 ) y_vect.append( 0.0 ) y_vect.append( graph_height ) y_vect.append( graph_height ) if( graph_positive ): x_vect.append( start ) x_vect.append( end ) x_vect.append( end ) x_vect.append( start ) else: x_vect.append( -start ) x_vect.append( -end ) x_vect.append( -end ) x_vect.append( -start ) =09 p =3D fill(x_vect, y_vect, colour) setp(p, linewidth=3D0.0) setp(p, alpha=3D0.4) def draw_needle( graph_positive, true_value, true_limits, graph_height, = graph_width, graph_center): x_vect =3D [] y_vect =3D [] =09 if( true_value =3D=3D None ): text( graph_center, (graph_height + 0.05), "N/A", size=3D10, = va=3D'bottom', ha=3D'center') else: #Clamp the value to the limits value =3D true_value * graph_width / (true_limits[1]-true_limits[0]) if( true_value < true_limits[0] ): value =3D true_limits[0] * graph_width / = (true_limits[1]-true_limits[0]) if( true_value > true_limits[1] ): value =3D true_limits[1] * graph_width / = (true_limits[1]-true_limits[0]) =09 text( value, (graph_height + 0.05), "%.2f" % true_value, size=3D10, = va=3D'bottom', ha=3D'center')=20 =09 if( not graph_positive ): value =3D -value =09 y_vect.append( graph_height/2 ) y_vect.append( graph_height ) y_vect.append( graph_height ) x_vect.append( value + 0.00 ) x_vect.append( value - 0.1 ) x_vect.append( value + 0.1 ) =09 fill(x_vect, y_vect, 'black') =09 =09 =09 def draw_ticks( graph_positive, scaled_limits, true_limits, = graph_height): if( graph_positive ): offset =3D scaled_limits[0] else: offset =3D scaled_limits[1] i =3D 0 j =3D true_limits[0] while( i*scaled_limits[3] + scaled_limits[0] <=3D scaled_limits[1] ): x_vect =3D [] y_vect =3D [] if( i % (scaled_limits[2]/scaled_limits[3]) =3D=3D 0): tick_length =3D graph_height if( type(true_limits[2]) is types.FloatType ): text( offset, -0.05, "%.2f" % j, size=3D10, va=3D'top', = ha=3D'center')=20 else: text( offset, -0.05, "%d" % int(j), size=3D10, va=3D'top', = ha=3D'center')=20 j +=3D true_limits[2] else: tick_length =3D graph_height * 0.2 y_vect.append( 0.0 ) y_vect.append( tick_length ) x_vect.append( offset ) x_vect.append( offset ) p =3D plot(x_vect, y_vect, 'b-') setp(p, linewidth=3D1) setp(p, color=3D'black') setp(p, alpha=3D0.2) i +=3D 1 if( graph_positive ): offset +=3D scaled_limits[3] else: offset -=3D scaled_limits[3] =09 if( i % (scaled_limits[2]/scaled_limits[3]) =3D=3D 0): if( type(true_limits[2]) is types.FloatType ): text( offset, -0.05, "%.2f" % j, size=3D10, va=3D'top', = ha=3D'center')=20 else: text( offset, -0.05, "%d" % int(j), size=3D10, va=3D'top', = ha=3D'center')=20 =09 def draw_widget( true_value, true_limits, true_zones, attribute_name, = filename, resolution=3D72 ): graph_height =3D 0.3 graph_width =3D 2.0 fig_height =3D graph_height + 1.0 fig_width =3D graph_width + 0.4 =09 #Perform Checking if( true_limits[0] =3D=3D true_limits[1] ): raise 'identical_limits_exception', true_limits if( true_limits[1] > true_limits[0] ): graph_positive =3D True else: #Swap the limits around graph_positive =3D False temp =3D true_limits[0] true_limits[0] =3D true_limits[1] true_limits[1] =3D temp =09 if not( ((limits[2]/limits[3]) % 1.0) * limits[3] =3D=3D 0 ): #There = must be an integer number of minor ticks for each major tick raise 'bad_tick_spacing_exception' if( true_limits[2] <=3D 0 or true_limits[3] <=3D 0 or true_limits[2] < = true_limits[3] or true_limits[3] > abs(true_limits[1]-true_limits[0]) ): raise 'bad_limits_exception', true_limits for zone in true_zones: if( zone[0] > zone[1] ): #Swap the zones so zone[1] > zone[0] temp =3D zone[0] zone[0] =3D zone[1] zone[1] =3D temp if( zone[1] < true_limits[0] or zone[0] > true_limits[1] ): raise 'bad_zone_exception', zone if( zone[0] < true_limits[0] ): zone[0] =3D true_limits[0] if( zone[1] > true_limits[1] ): zone[1] =3D true_limits[1] =09 #Adjust the scaling scaled_limits =3D [] for limit in true_limits: scaled_limits.append( limit * graph_width / = (true_limits[1]-true_limits[0])) =09 =09 figure(figsize=3D(fig_width, fig_height )) a =3D axes([(0.2/fig_width), (0.5/fig_height), (graph_width/fig_width), = (graph_height/fig_height)]) setp(a, xlim=3D( 0, graph_width ), ylim=3D( 0, graph_height ), = xticks=3D[], yticks=3D[]) =09 =09 #Draw the meter graph_center =3D ((scaled_limits[1]+scaled_limits[0])/2) for zone in true_zones: draw_bar(graph_positive, graph_height, (zone[0] * graph_width / = (true_limits[1]-true_limits[0])), (zone[1] * graph_width / = (true_limits[1]-true_limits[0])), zone[2]) draw_ticks( graph_positive, scaled_limits, true_limits, graph_height ) draw_needle( graph_positive, true_value, true_limits, graph_height, = graph_width, graph_center ) text( graph_center, graph_height+0.25, attribute_name, size=3D12, = va=3D'bottom', ha=3D'center') =09 setp(gca(), xlim=3D( scaled_limits[0], scaled_limits[1] )) =09 savefig( filename, dpi=3Dresolution) #draw_widget( None, [4.0,20.0,4,0.1], = [[4.0,10.0,'r'],[10.0,14.0,'y'],[14.0,20.0,'g']], "Rx MOS (24h)", = "gauge_0.png", 100) #draw_widget( 1.2, [4.0,10.0,2,0.5], = [[4.0,6.0,'r'],[6.0,8.0,'y'],[8.0,10.0,'g']], "Rx MOS (24h)", = "gauge_1.png", 100) #draw_widget( -4.0, [-10.0,10.0,5.0,1.0], = [[-10.0,0.0,'r'],[0.0,5.0,'y'],[5.0,10.0,'g']], "Rx MOS (24h)", = "gauge_2.png", 100) #draw_widget( -4.0, [-20.0,-4.0,4.0,1.0], = [[-4.0,-10.0,'r'],[-10.0,-14.0,'y'],[-14.0,-20.0,'g']], "Rx MOS (24h)", = "gauge_0.png", 100) #draw_widget( -11.36, [-40.0,-10.0,5.0,2.5], = [[-40.0,-35.0,'y'],[-35.0,-15.0,'g'],[-15.0,10.0,'y']], "Rx MOS (24h)", = "gauge_0.png", 100) #show() =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= linear vertical gauge =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= #!/usr/bin/env python # # This program draws a vertical linear meter. You supply limits, # shaded regions, names and the current value, and invoke=20 # it like this: # # draw_widget( current_value,=20 # limits[ lower, upper, major ticks, minor ticks], # shaded zones [ [lower,upper,colour], # [lower,upper,colour], # ...],=20 # name "MOS",=20 # filename "v_meter_0.png", # resolution in dpi # ) # # from pylab import * import types #from matplotlib.patches import Patch, Rectangle, Circle, Polygon, = Wedge, Shadow, bbox_artist #import math def draw_bar( graph_positive, graph_width, start, end, colour): x_vect =3D [] y_vect =3D [] =09 if not ( graph_positive ): start =3D -start end =3D -end =09 =09 =09 =09 x_vect.append( 0.0 ) x_vect.append( 0.0 ) x_vect.append( graph_width ) x_vect.append( graph_width ) y_vect.append( start ) y_vect.append( end ) y_vect.append( end ) y_vect.append( start ) =09 p =3D fill(x_vect, y_vect, colour) setp(p, linewidth=3D0.0) setp(p, alpha=3D0.4) def draw_needle( graph_positive, true_value, true_limits, graph_width, = graph_height, graph_center ): x_vect =3D [] y_vect =3D [] =09 if( true_value =3D=3D None ): text( (graph_width + 0.05), graph_center, "N/A", size=3D10, = va=3D'center', ha=3D'left')=20 else: #Clamp the value to the limits value =3D true_value * graph_height / (true_limits[1]-true_limits[0]) if( true_value < true_limits[0] ): value =3D true_limits[0] * graph_height / = (true_limits[1]-true_limits[0]) if( true_value > true_limits[1] ): value =3D true_limits[1] * graph_height / = (true_limits[1]-true_limits[0]) =09 text( (graph_width + 0.05), value, "%.2f" % true_value, size=3D10, = va=3D'center', ha=3D'left')=20 if( not graph_positive ): value =3D -value =09 =09 x_vect.append( graph_width/2 ) x_vect.append( graph_width ) x_vect.append( graph_width ) y_vect.append( value + 0.00 ) y_vect.append( value - 0.1 ) y_vect.append( value + 0.1 ) =09 fill(x_vect, y_vect, 'black') =09 =09 def draw_ticks( graph_positive, scaled_limits, true_limits, = graph_width): if( graph_positive ): offset =3D scaled_limits[0] else: offset =3D scaled_limits[1] i =3D 0 j =3D true_limits[0] while( i*scaled_limits[3] + scaled_limits[0] <=3D scaled_limits[1] ): x_vect =3D [] y_vect =3D [] if( i % (scaled_limits[2]/scaled_limits[3]) =3D=3D 0): tick_length =3D graph_width if( type(true_limits[2]) is types.FloatType ): text(-0.05, offset, "%.2f" % j, size=3D10, va=3D'center', = ha=3D'right') else:=20 text(-0.05, offset, "%d" % int(j), size=3D10, va=3D'center', = ha=3D'right') j +=3D true_limits[2] else: tick_length =3D graph_width * 0.2 x_vect.append( 0.0 ) x_vect.append( tick_length ) y_vect.append( offset ) y_vect.append( offset ) p =3D plot(x_vect, y_vect, 'b-') setp(p, linewidth=3D1) setp(p, color=3D'black') setp(p, alpha=3D0.2) i +=3D 1 if( graph_positive ): offset +=3D scaled_limits[3] else: offset -=3D scaled_limits[3] =09 if( i % (scaled_limits[2]/scaled_limits[3]) =3D=3D 0): if( type(true_limits[2]) is types.FloatType ): text(-0.05, offset, "%.2f" % j, size=3D10, va=3D'center', = ha=3D'right') else:=20 text(-0.05, offset, "%d" % int(j), size=3D10, va=3D'center', = ha=3D'right') =09 def draw_widget( true_value, true_limits, true_zones, attribute_name, = filename, resolution=3D72 ): graph_height =3D 2.0 graph_width =3D 0.3 fig_height =3D graph_height + 0.4 fig_width =3D graph_width + 1.0 =09 figure(figsize=3D(fig_width, fig_height )) a =3D axes([(0.5/fig_width), (0.3/fig_height), (graph_width/fig_width), = (graph_height/fig_height)]) setp(a, xlim=3D( 0, graph_width ), ylim=3D( 0, graph_height ), = xticks=3D[], yticks=3D[]) =09 #Perform Checking if( true_limits[0] =3D=3D true_limits[1] ): raise 'identical_limits_exception', true_limits if( true_limits[1] > true_limits[0] ): graph_positive =3D True else: #Swap the limits around graph_positive =3D False temp =3D true_limits[0] true_limits[0] =3D true_limits[1] true_limits[1] =3D temp =09 if not( ((limits[2]/limits[3]) % 1.0) * limits[3] =3D=3D 0 ): #There = must be an integer number of minor ticks for each major tick raise 'bad_tick_spacing_exception' if( true_limits[2] <=3D 0 or true_limits[3] <=3D 0 or true_limits[2] < = true_limits[3] or true_limits[3] > abs(true_limits[1]-true_limits[0]) ): raise 'bad_limits_exception', true_limits for zone in true_zones: if( zone[0] > zone[1] ): #Swap the zones so zone[1] > zone[0] temp =3D zone[0] zone[0] =3D zone[1] zone[1] =3D temp if( zone[1] < true_limits[0] or zone[0] > true_limits[1] ): raise 'bad_zone_exception', zone if( zone[0] < true_limits[0] ): zone[0] =3D true_limits[0] if( zone[1] > true_limits[1] ): zone[1] =3D true_limits[1] =09 #Adjust the scaling scaled_limits =3D [] for limit in true_limits: scaled_limits.append( limit * graph_height / = (true_limits[1]-true_limits[0])) =09 =09 =09 #Draw the meter graph_center =3D ((true_limits[1]+true_limits[0])/2* graph_height / = (true_limits[1]-true_limits[0])) for zone in true_zones: draw_bar(graph_positive, graph_width, (zone[0] * graph_height / = (true_limits[1]-true_limits[0])), (zone[1] * graph_height / = (true_limits[1]-true_limits[0])), zone[2]) draw_ticks( graph_positive, scaled_limits, true_limits, graph_width) draw_needle( graph_positive, true_value, true_limits, graph_width, = graph_height, graph_center ) text((graph_width/2), (scaled_limits[0]-0.1), attribute_name, = size=3D12, va=3D'top', ha=3D'center') =09 setp(gca(), ylim=3D( scaled_limits[0], scaled_limits[1] )) =09 savefig( filename, dpi=3Dresolution) #draw_widget( None, [4.0,20.0,4,1.0], = [[4.0,10.0,'r'],[10.0,14.0,'y'],[14.0,20.0,'g']], "Rx MOS (24h)", = "gauge_0.png", 100) #draw_widget( -10.0, [-20.0,-4.0,4.0,1.0], = [[-4.0,-10.0,'r'],[-10.0,-14.0,'y'],[-14.0,-20.0,'g']], "Rx MOS (24h)", = "gauge_0.png", 100) #draw_widget( -4.5, [20.0,-20.0,4.0,1.0], = [[12.5-20.0,-15.0,'r'],[-10.0,-15.0,'y'],[-10.0,20.0,'g']], "Rx MOS = (24h)", "gauge_0.png", 100) #show() =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= logarithmic rotary gauge =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= #!/usr/bin/env python # # This program draws a log semi-circular gauge. You supply limits, # shaded regions, names and the current value, and invoke=20 # it like this: # draw_widget( current_value,=20 # limits[ left, right], # shaded zones [ [lower,upper,colour], # [lower,upper,colour], # ...],=20 # name "MOS",=20 # filename "gauge_0.png", # resolution in dpi # ) # # NOTE: The limits you specify must be of this form # for any value of 'n': 1.0*10^n # from pylab import * #from matplotlib.patches import Patch, Rectangle, Circle, Polygon, = Wedge, Shadow, bbox_artist import math import matplotlib matplotlib.use('Agg') # force the antigrain backend from matplotlib.backends.backend_agg import FigureCanvasAgg def draw_arch(limits, start, end, colour, border, graph_positive): x_vect =3D [] y_vect =3D [] if( graph_positive ): start_value =3D int(180 - (start - limits[0]) * = (180.0/(limits[1]-limits[0]))) end_value =3D int(180 - (end - limits[0]) * = (180.0/(limits[1]-limits[0]))) else: start_value =3D int( (end - limits[0]) * = (180.0/(limits[1]-limits[0]))) end_value =3D int( (start - limits[0]) * = (180.0/(limits[1]-limits[0]))) =09 =09 if( graph_positive ): start_value =3D (math.log10(start) - math.log10(limits[1])) * 180.00 / = -(math.log10(limits[1]) - math.log10(limits[0])) end_value =3D (math.log10(end) - math.log10(limits[1])) * 180.00 / = -(math.log10(limits[1]) - math.log10(limits[0])) else: start_value =3D (math.log10(end) - math.log10(limits[0])) * 180.00 / = +(math.log10(limits[1]) - math.log10(limits[0])) end_value =3D (math.log10(start) - math.log10(limits[0])) * 180.00 = / +(math.log10(limits[1]) - math.log10(limits[0])) =09 #Draw the arch theta =3D start_value radius =3D 0.85 while (theta >=3D end_value): x_vect.append( radius * math.cos(theta * (pi/180)) ) y_vect.append( radius * math.sin(theta * (pi/180)) ) theta -=3D 1 =09 theta =3D end_value radius =3D 1.0 while (theta <=3D start_value): x_vect.append( radius * math.cos(theta * (pi/180)) ) y_vect.append( radius * math.sin(theta * (pi/180)) ) theta +=3D 1 =09 if( border ): #Close the loop x_vect.append(-0.85) y_vect.append(0.0) =09 p =3D plot(x_vect, y_vect, 'b-') setp(p, color=3D'black') setp(p, linewidth=3D1.5) else: p =3D fill(x_vect, y_vect, colour) setp(p, linewidth=3D0.0) setp(p, alpha=3D0.4) =09 def draw_needle(current_value, limits, graph_positive): x_vect =3D [] y_vect =3D [] =09 if current_value =3D=3D None: text(0.0, 0.0, "N/A", size=3D10, va=3D'center', ha=3D'center') else: text(0.0, 0.0, "%.2f" % current_value, size=3D10, va=3D'center', = ha=3D'center') =09 #Clamp the value to the limits if( current_value < limits[0] ): current_value =3D limits[0] if( current_value > limits[1] ): current_value =3D limits[1] =09 =09 theta =3D 0 length =3D 0.95 #if( graph_positive ):=09 # angle =3D 180 - (current_value - limits[0]) = *(180.0/(limits[1]-limits[0])) #else: # angle =3D (current_value - limits[0]) = *(180.0/(limits[1]-limits[0])) =09 if( graph_positive ): angle =3D (math.log10(current_value) - math.log10(limits[1])) * = 180.00 / -(math.log10(limits[1]) - math.log10(limits[0])) else: angle =3D (math.log10(current_value) - math.log10(limits[0])) * = 180.00 / +(math.log10(limits[1]) - math.log10(limits[0])) =09 #angle =3D 180.0-180.0*(current_value/(limits[1] - limits[0]))=20 #while (theta <=3D 270): =09 x_vect.append( length * math.cos((theta + angle) * (pi/180)) ) y_vect.append( length * math.sin((theta + angle) * (pi/180)) ) x_vect.append( 0.2 * length * math.cos((theta + angle + 10.0) * = (pi/180)) ) y_vect.append( 0.2 * length * math.sin((theta + angle + 10.0) * = (pi/180)) ) x_vect.append( 0.15 * length * math.cos((theta + angle ) * (pi/180)) ) y_vect.append( 0.15 * length * math.sin((theta + angle ) * (pi/180)) ) x_vect.append( 0.2 * length * math.cos((theta + angle - 10.0) * = (pi/180)) ) y_vect.append( 0.2 * length * math.sin((theta + angle - 10.0) * = (pi/180)) ) =09 # length =3D 0.05 # theta +=3D 90 =09 p =3D fill(x_vect, y_vect, 'b') setp(p, alpha=3D0.4) =09 =09 =09 def draw_ticks(limits, graph_positive): if( graph_positive ): angle =3D 180.0 else: angle =3D 0.0 =09 i =3D limits[0] step =3D limits[0] x_vect =3D [] y_vect =3D [] while( i < limits[1] ): while( i < (step * 10) ): x_vect =3D [] y_vect =3D [] value =3D math.log10(i) if( graph_positive ): angle =3D (value - math.log10(limits[1])) * 180.00 / = -(math.log10(limits[1]) - math.log10(limits[0])) else: angle =3D (value - math.log10(limits[0])) * 180.00 / = +(math.log10(limits[1]) - math.log10(limits[0])) x_pos =3D 1.1 * math.cos( angle * (pi/180.0)) y_pos =3D 1.1 * math.sin( angle * (pi/180.0)) mantissa =3D int(i / math.pow(10, math.ceil(math.log10(i))-1)) if( mantissa =3D=3D 10 or mantissa =3D=3D 1 ): print i, mantissa text( x_pos, y_pos, "%g" % i, size=3D10, va=3D'center', = ha=3D'center', rotation=3D(angle - 90))=20 tick_length =3D 0.15 else: tick_length =3D 0.05 x_vect.append( 1.0 * math.cos( angle * (pi/180.0))) x_vect.append( (1.0 - tick_length) * math.cos( angle * (pi/180.0))) y_vect.append( 1.0 * math.sin( angle * (pi/180.0))) y_vect.append( (1.0 - tick_length) * math.sin( angle * (pi/180.0))) p =3D plot(x_vect, y_vect, 'b-') setp(p, linewidth=3D1) setp(p, alpha=3D0.4) setp(p, color=3D"black") =09 i +=3D step i =3D step * 10 step =3D step * 10 i =3D limits[1] value =3D math.log10(i) if( graph_positive ): angle =3D (value - math.log10(limits[1])) * 180.00 / = -(math.log10(limits[1]) - math.log10(limits[0])) else: angle =3D (value - math.log10(limits[0])) * 180.00 / = +(math.log10(limits[1]) - math.log10(limits[0])) x_pos =3D 1.1 * math.cos( angle * (pi/180.0)) y_pos =3D 1.1 * math.sin( angle * (pi/180.0)) mantissa =3D int(i / math.pow(10, math.ceil(math.log10(i))-1)) if( mantissa =3D=3D 10 ): text( x_pos, y_pos, "%g" % i, size=3D10, va=3D'center', ha=3D'center', = rotation=3D(angle - 90))=20 =09 =09 =09 def draw_bounding_box(graph_width, graph_height): x_vect =3D [] y_vect =3D [] =09 x_vect.append( (graph_width/2) ) x_vect.append( (graph_width/2) ) x_vect.append(-(graph_width/2) ) x_vect.append(-(graph_width/2) ) x_vect.append( (graph_width/2) ) =09 y_vect.append(-0.1) y_vect.append(graph_height) y_vect.append(graph_height) y_vect.append(-0.1) y_vect.append(-0.1) =09 p =3D plot(x_vect, y_vect, 'r-') setp(p, linewidth=3D0) =09 =09 def draw_widget( current_value, limits, zone_colour, attribute_name, = filename, resolution=3D72 ): graph_height =3D 1.4 graph_width =3D 2.4 fig_height =3D graph_height fig_width =3D graph_width =09 figure(figsize=3D(fig_width, fig_height )) a =3D axes([(0.0/fig_width), (0.0/fig_height), (graph_width/fig_width), = (graph_height/fig_height)]) setp(a, xlim=3D( -0.1, graph_width+0.1 ), ylim=3D( -0.2, = graph_height+0.1 ), xticks=3D[], yticks=3D[]) axis('off') =09 #Perform Checking if( limits[0] =3D=3D limits[1] ): raise 'identical_limits_exception', limits if( limits[1] > limits[0] ): graph_positive =3D True else: #Swap the limits around graph_positive =3D False temp =3D limits[0] limits[0] =3D limits[1] limits[1] =3D temp =09 if not( math.log10(limits[0]) % 1.0 =3D=3D 0 and math.log10(limits[1]) = % 1.0 =3D=3D 0 ): raise 'bad_limits_exception' =09 for zone in zone_colour: if( zone[0] > zone[1] ): #Swap the zones so zone[1] > zone[0] temp =3D zone[0] zone[0] =3D zone[1] zone[1] =3D temp if( zone[1] < limits[0] or zone[0] > limits[1] ): raise 'bad_zone_exception', zone if( zone[0] < limits[0] ): zone[0] =3D limits[0] if( zone[1] > limits[1] ): zone[1] =3D limits[1] =09 #Draw the arch for zone in zone_colour: draw_arch(limits, zone[0], zone[1], zone[2], False, graph_positive) draw_arch(limits, limits[0], limits[1], 'black', True, graph_positive) draw_ticks(limits, graph_positive) draw_needle(current_value, limits, graph_positive) draw_bounding_box(graph_width, graph_height) text(0.0, 0.3, attribute_name, size=3D10, va=3D'center', ha=3D'center') =09 savefig( filename, dpi=3Dresolution) #draw_widget( 0.02, [0.0001,1.0], [[0.0001,0.01,'g'], = [0.01,0.05,'y'],[0.05,1.0,'r']], "Sat. Clipping", "log_0.png", 100) #draw_widget( 0.02, [10.0,0.001], [[0.001,0.1,'g'], = [0.1,0.5,'y'],[0.5,10.0,'r']], "Sat. Clipping", "log_0.png", 100) #draw_widget( 0.02, [10.0,0.001], [[0.001,0.1,'g'], = [0.1,0.5,'y'],[0.5,8.0,'r']], "Sat. Clipping", "log_0.png", 100) #draw_widget( 20.0, [1000.0,1.0], [[1.0,10.0,'g'], = [10.0,100.0,'y'],[100.0,1000.0,'r']], "Sat. Clipping", "log_0.png", 100) #show() =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= logarithmic horizontal gauge =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= #!/usr/bin/env python # # This program draws a log horizontal gauge. You supply limits, # shaded regions, names and the current value, and invoke=20 # it like this: # draw_widget( current_value,=20 # limits[ left, right], # shaded zones [ [lower,upper,colour], # [lower,upper,colour], # ...],=20 # name "MOS",=20 # filename "gauge_0.png", # resolution in dpi # ) # # NOTE: The limits you specify must be of this form # for any value of 'n': 1.0*10^n # from pylab import * #from matplotlib.patches import Patch, Rectangle, Circle, Polygon, = Wedge, Shadow, bbox_artist import math import matplotlib matplotlib.use('Agg') # force the antigrain backend from matplotlib.backends.backend_agg import FigureCanvasAgg def draw_arch(limits, start, end, colour, graph_width, graph_positive): x_vect =3D [] y_vect =3D [] =09 if( graph_positive ): start_value =3D math.log10(start) end_value =3D math.log10(end) else: start_value =3D - math.log10(start) end_value =3D - math.log10(end) =09 y_vect.append( 0.0 ) y_vect.append( 0.0 ) y_vect.append( graph_width ) y_vect.append( graph_width ) x_vect.append( start_value ) x_vect.append( end_value ) x_vect.append( end_value ) x_vect.append( start_value ) =09 p =3D fill(x_vect, y_vect, colour) setp(p, linewidth=3D0.0) setp(p, alpha=3D0.4) =09 def draw_needle(current_value, limits, graph_positive, graph_width, = graph_center): x_vect =3D [] y_vect =3D [] =09 if current_value =3D=3D None: text( (graph_width + 0.1), graph_center, "N/A", size=3D10, = va=3D'center', ha=3D'left')=20 else: #Clamp the value to the limits if( current_value < limits[0] ): current_value =3D limits[0] if( current_value > limits[1] ): current_value =3D limits[1] if( graph_positive ): offset =3D math.log10(current_value) else: offset =3D -math.log10(current_value) text( offset, (graph_width + 0.1), "%g" % current_value, size=3D10, = va=3D'center', ha=3D'left') =09 y_vect.append( graph_width/2 ) y_vect.append( graph_width ) y_vect.append( graph_width ) x_vect.append( offset + 0.00 ) x_vect.append( offset - 0.1 ) x_vect.append( offset + 0.1 ) =09 fill(x_vect, y_vect, 'black') =09 =09 def draw_ticks(limits, graph_positive, graph_width): i =3D limits[0] step =3D limits[0] x_vect =3D [] y_vect =3D [] while( i < limits[1] ): while( i < (step * 10) ): x_vect =3D [] y_vect =3D [] value =3D math.log10(i) if( graph_positive ): offset =3D value else: offset =3D-value x_pos =3D 1.1 * math.cos( offset * (pi/180.0)) y_pos =3D 1.1 * math.sin( offset * (pi/180.0)) mantissa =3D int(i / math.pow(10, math.ceil(math.log10(i))-1)) if( mantissa =3D=3D 10 or mantissa =3D=3D 1 ): text( offset, -0.05, "%g" % i, size=3D10, va=3D'top', ha=3D'center') = tick_length =3D graph_width else: tick_length =3D graph_width * 0.2 y_vect.append( 0.0 ) y_vect.append( tick_length ) x_vect.append( offset ) x_vect.append( offset ) p =3D plot(x_vect, y_vect, 'b-') setp(p, linewidth=3D1) setp(p, color=3D'black') setp(p, alpha=3D0.2) =09 i +=3D step i =3D step * 10 step =3D step * 10 i =3D limits[1] value =3D math.log10(i) if( graph_positive ): offset =3D value else: offset =3D-value mantissa =3D int(i / math.pow(10, math.ceil(math.log10(i))-1)) if( mantissa =3D=3D 10 ): text( offset, -0.05, "%g" % i, size=3D10, va=3D'top', ha=3D'center')=20 =09 =09 def draw_widget( current_value, limits, zone_colour, attribute_name, = filename, resolution=3D72 ): graph_height =3D 0.3 graph_width =3D 2.0 fig_height =3D graph_height + 1.0 fig_width =3D graph_width + 0.4 =09 figure(figsize=3D(fig_width, fig_height )) a =3D axes([(0.2/fig_width), (0.5/fig_height), (graph_width/fig_width), = (graph_height/fig_height)]) setp(a, xlim=3D( 0.0, graph_width ), ylim=3D( 0.0, graph_height ), = xticks=3D[], yticks=3D[]) =09 #Perform Checking if( limits[0] =3D=3D limits[1] ): raise 'identical_limits_exception', limits if( limits[1] > limits[0] ): graph_positive =3D True else: #Swap the limits around graph_positive =3D False temp =3D limits[0] limits[0] =3D limits[1] limits[1] =3D temp =09 if not( math.log10(limits[0]) % 1.0 =3D=3D 0 and math.log10(limits[1]) = % 1.0 =3D=3D 0 ): raise 'bad_limits_exception' =09 =09 for zone in zone_colour: if( zone[0] > zone[1] ): #Swap the zones so zone[1] > zone[0] temp =3D zone[0] zone[0] =3D zone[1] zone[1] =3D temp if( zone[1] < limits[0] or zone[0] > limits[1] ): raise 'bad_zone_exception', zone if( zone[0] < limits[0] ): zone[0] =3D limits[0] if( zone[1] > limits[1] ): zone[1] =3D limits[1] =09 #Draw the arch graph_center =3D ((math.log10(limits[1])+math.log10(limits[0]))/2.0) for zone in zone_colour: draw_arch(limits, zone[0], zone[1], zone[2], graph_height, = graph_positive) draw_ticks(limits, graph_positive, graph_height) draw_needle(current_value, limits, graph_positive, graph_height, = graph_center) if( graph_positive ): setp(gca(), xlim=3D( math.log10(limits[0]), math.log10(limits[1]) )) text( graph_center, -0.3, attribute_name, size=3D12, va=3D'top', = ha=3D'center') else: setp(gca(), xlim=3D( -math.log10(limits[1]), -math.log10(limits[0]) )) text( -graph_center, -0.3, attribute_name, size=3D12, va=3D'top', = ha=3D'center') =09 savefig( filename, dpi=3Dresolution) =09 #draw_widget( 0.02, [0.0001,1.0], [[0.0001,0.01,'g'], = [0.01,0.05,'y'],[0.05,1.0,'r']], "Normal", "log_0.png", 100) #draw_widget( 0.02, [1.0,0.0001], [[0.0001,0.01,'g'], = [0.01,0.05,'y'],[0.05,1.0,'r']], "Backwards", "log_0.png", 100) #draw_widget( 0.02, [0.001,10.0], [[0.001,0.1,'g'], = [0.1,0.5,'y'],[0.5,10.0,'r']], "None", "log_0.png", 100) #draw_widget( 0.20, [10.0,0.001], [[0.001,0.1,'g'], = [0.1,0.5,'y'],[0.5,10.0,'r']], "Shmoo", "log_0.png", 100) #draw_widget( 20.0, [1000.0,1.0], [[1.0,10.0,'g'], = [10.0,100.0,'y'],[100.0,1000.0,'r']], "> 1.0", "log_0.png", 100) #show() =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= logarithmic vertical gauge =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= #!/usr/bin/env python # # This program draws a log vertical gauge. You supply limits, # shaded regions, names and the current value, and invoke=20 # it like this: # draw_widget( current_value,=20 # limits[ left, right], # shaded zones [ [lower,upper,colour], # [lower,upper,colour], # ...],=20 # name "MOS",=20 # filename "gauge_0.png", # resolution in dpi # ) # # NOTE: The limits you specify must be of this form # for any value of 'n': 1.0*10^n # from pylab import * #from matplotlib.patches import Patch, Rectangle, Circle, Polygon, = Wedge, Shadow, bbox_artist import math import matplotlib matplotlib.use('Agg') # force the antigrain backend from matplotlib.backends.backend_agg import FigureCanvasAgg def draw_arch(limits, start, end, colour, graph_width, graph_positive): x_vect =3D [] y_vect =3D [] =09 if( graph_positive ): start_value =3D math.log10(start) end_value =3D math.log10(end) else: start_value =3D - math.log10(start) end_value =3D - math.log10(end) =09 x_vect.append( 0.0 ) x_vect.append( 0.0 ) x_vect.append( graph_width ) x_vect.append( graph_width ) y_vect.append( start_value ) y_vect.append( end_value ) y_vect.append( end_value ) y_vect.append( start_value ) =09 p =3D fill(x_vect, y_vect, colour) setp(p, linewidth=3D0.0) setp(p, alpha=3D0.4) =09 def draw_needle(current_value, limits, graph_positive, graph_width, = graph_center): x_vect =3D [] y_vect =3D [] =09 if current_value =3D=3D None: text( (graph_width + 0.05), graph_center, "N/A", size=3D10, = va=3D'center', ha=3D'left')=20 else: #Clamp the value to the limits if( current_value < limits[0] ): current_value =3D limits[0] if( current_value > limits[1] ): current_value =3D limits[1] if( graph_positive ): offset =3D math.log10(current_value) else: offset =3D -math.log10(current_value) text( (graph_width + 0.05), offset, "%g" % current_value, size=3D10, = va=3D'center', ha=3D'left') =09 x_vect.append( graph_width/2 ) x_vect.append( graph_width ) x_vect.append( graph_width ) y_vect.append( offset + 0.00 ) y_vect.append( offset - 0.1 ) y_vect.append( offset + 0.1 ) =09 fill(x_vect, y_vect, 'black') =09 =09 def draw_ticks(limits, graph_positive, graph_width): i =3D limits[0] step =3D limits[0] x_vect =3D [] y_vect =3D [] while( i < limits[1] ): while( i < (step * 10) ): x_vect =3D [] y_vect =3D [] value =3D math.log10(i) if( graph_positive ): offset =3D value else: offset =3D-value x_pos =3D 1.1 * math.cos( offset * (pi/180.0)) y_pos =3D 1.1 * math.sin( offset * (pi/180.0)) mantissa =3D int(i / math.pow(10, math.ceil(math.log10(i))-1)) if( mantissa =3D=3D 10 or mantissa =3D=3D 1 ): text(-0.05, offset, "%g" % i, size=3D10, va=3D'center', = ha=3D'right')=20 tick_length =3D graph_width else: tick_length =3D graph_width * 0.2 x_vect.append( 0.0 ) x_vect.append( tick_length ) y_vect.append( offset ) y_vect.append( offset ) p =3D plot(x_vect, y_vect, 'b-') setp(p, linewidth=3D1) setp(p, color=3D'black') setp(p, alpha=3D0.2) =09 i +=3D step i =3D step * 10 step =3D step * 10 i =3D limits[1] value =3D math.log10(i) if( graph_positive ): offset =3D value else: offset =3D-value x_pos =3D 1.1 * math.cos( offset * (pi/180.0)) y_pos =3D 1.1 * math.sin( offset * (pi/180.0)) mantissa =3D int(i / math.pow(10, math.ceil(math.log10(i))-1)) if( mantissa =3D=3D 10 ): text(-0.05, offset, "%g" % i, size=3D10, va=3D'center', ha=3D'right')=20 =09 =09 def draw_widget( current_value, limits, zone_colour, attribute_name, = filename, resolution=3D72 ): graph_height =3D 2.0 graph_width =3D 0.3 fig_height =3D graph_height + 0.4 fig_width =3D graph_width + 1.0 =09 figure(figsize=3D(fig_width, fig_height )) a =3D axes([(0.5/fig_width), (0.3/fig_height), (graph_width/fig_width), = (graph_height/fig_height)]) setp(a, xlim=3D( 0.0, graph_width ), ylim=3D( 0.0, graph_height ), = xticks=3D[], yticks=3D[]) =09 #Perform Checking if( limits[0] =3D=3D limits[1] ): raise 'identical_limits_exception', limits if( limits[1] > limits[0] ): graph_positive =3D True else: #Swap the limits around graph_positive =3D False temp =3D limits[0] limits[0] =3D limits[1] limits[1] =3D temp =09 if not( math.log10(limits[0]) % 1.0 =3D=3D 0 and math.log10(limits[1]) = % 1.0 =3D=3D 0 ): raise 'bad_limits_exception' =09 =09 for zone in zone_colour: if( zone[0] > zone[1] ): #Swap the zones so zone[1] > zone[0] temp =3D zone[0] zone[0] =3D zone[1] zone[1] =3D temp if( zone[1] < limits[0] or zone[0] > limits[1] ): raise 'bad_zone_exception', zone if( zone[0] < limits[0] ): zone[0] =3D limits[0] if( zone[1] > limits[1] ): zone[1] =3D limits[1] =09 #Draw the arch graph_center =3D ((math.log10(limits[1])+math.log10(limits[0]))/2.0) for zone in zone_colour: draw_arch(limits, zone[0], zone[1], zone[2], graph_width, = graph_positive) draw_ticks(limits, graph_positive, graph_width) draw_needle(current_value, limits, graph_positive, graph_width, = graph_center) if( graph_positive ): setp(gca(), ylim=3D( math.log10(limits[0]), math.log10(limits[1]) )) text((graph_width/2), (math.log10(limits[0])-0.1), attribute_name, = size=3D12, va=3D'top', ha=3D'center') else: setp(gca(), ylim=3D( -math.log10(limits[1]), -math.log10(limits[0]) )) text((graph_width/2), -(math.log10(limits[1])+0.1), attribute_name, = size=3D12, va=3D'top', ha=3D'center') =09 savefig( filename, dpi=3Dresolution) =09 #draw_widget( 0.02, [0.0001,1.0], [[0.0001,0.01,'g'], = [0.01,0.05,'y'],[0.05,1.0,'r']], "Normal", "log_0.png", 100) #draw_widget( 0.02, [1.0,0.0001], [[0.0001,0.01,'g'], = [0.01,0.05,'y'],[0.05,1.0,'r']], "Backwards", "log_0.png", 100) #draw_widget( 0.02, [0.001,10.0], [[0.001,0.1,'g'], = [0.1,0.5,'y'],[0.5,10.0,'r']], "None", "log_0.png", 100) #draw_widget( 0.20, [10.0,0.001], [[0.001,0.1,'g'], = [0.1,0.5,'y'],[0.5,10.0,'r']], "Shmoo", "log_0.png", 100) #draw_widget( 20.0, [1000.0,1.0], [[1.0,10.0,'g'], = [10.0,100.0,'y'],[100.0,1000.0,'r']], "> 1.0", "log_0.png", 100) #show() |
|
From: John H. <jdh...@ac...> - 2005-07-08 14:51:53
|
Normally, this would have been a bugfix release, but I reorganized the
matplotlib configuration files so thought it best to tick the version
number. All of the configuration files and dirs (matplotlibrc,
tex.cache, ttffont.cache ) now reside in $HOME/.matplotlib (on windows
C:\Documents and Settings\youracct\.matplotlib). Please rename your
.matplotlibrc file to matplotlibrc and put it there.
Other changes are
2005-07-07 Added Eric's MA set_xdata Line2D fix - JDH
2005-07-06 Made HOME/.matplotlib the new config dir where the
matplotlibrc file, the ttf.cache, and the tex.cache live.
The new default filenames in .matplotlib have no leading
dot and are not hidden. Eg, the new names are matplotlibrc
tex.cache ttffont.cache. This is how ipython does it so it
must be right. If old files are found, a warning is issued
and they are moved to the new location. Also fixed
texmanager to put all files, including temp files in
~/.matplotlib/tex.cache, which allows you to usetex in
non-writable dirs.
2005-07-05 Fixed bug #1231611 in subplots adjust layout. The problem
was that the text cacheing mechanism was not using the
transformation affine in the key. - JDH
2005-07-05 Fixed default backend import problem when using API (SF bug
# 1209354 - see API_CHANGES for more info - JDH
2005-07-04 backend_gtk.py: require PyGTK version 2.0.0 or higher - SC
2005-06-30 setupext.py: added numarray_inc_dirs for building against
numarray when not installed in standard location - ADS
2005-06-27 backend_svg.py: write figure width, height as int, not float.
Update to fix some of the pychecker warnings - SC
2005-06-23 Updated examples/agg_test.py to demonstrate curved paths
and fills - JDH
2005-06-21 Moved some texmanager and backend_agg tex caching to class
level rather than instance level - JDH
2005-06-20 setupext.py: fix problem where _nc_backend_gdk is installed to the
wrong directory - SC
2005-06-19 Added 10.4 support for CocoaAgg. - CM
2005-06-18 Move Figure.get_width_height() to FigureCanvasBase and return
int instead of float. - SC
2005-06-18 Applied Ted Drain's QtAgg patch: 1) Changed the toolbar to
be a horizontal bar of push buttons instead of a QToolbar
and updated the layout algorithms in the main window
accordingly. This eliminates the ability to drag and drop
the toolbar and detach it from the window. 2) Updated the
resize algorithm in the main window to show the correct
size for the plot widget as requested. This works almost
correctly right now. It looks to me like the final size of
the widget is off by the border of the main window but I
haven't figured out a way to get that information yet. We
could just add a small margin to the new size but that
seems a little hacky. 3) Changed the x/y location label to
be in the toolbar like the Tk backend instead of as a
status line at the bottom of the widget. 4) Changed the
toolbar pixmaps to use the ppm files instead of the png
files. I noticed that the Tk backend buttons looked much
nicer and it uses the ppm files so I switched them.
2005-06-17 Modified the gtk backend to not queue mouse motion events.
This allows for live updates when dragging a slider. - CM
2005-06-17 Added starter CocoaAgg backend. Only works on OS 10.3 for
now and requires PyObjC. (10.4 is high priority) - CM
2005-06-17 Upgraded pyparsing and applied Paul McGuire's suggestions
for speeding things up. This more than doubles the speed
of mathtext in my simple tests. JDH
2005-06-16 Applied David Cooke's subplot make_key patch
Downloads at http://matplotlib.sf.net
Enjoy!
JDH
|
|
From: Abraham S. <ab...@cn...> - 2005-07-08 02:36:52
|
That's good to know. I tried googling it, but I guess I should've also checked CVS as well. I'm sure it's better than my hack anyways -- just good to have my scripts working again. I tend to prefer the subplot(w, h, n) since most of my plotting is automated, and it's more of a pain to have to convert the parameters to a string first, etc. A Eric Firing wrote: > Abe, > > That bug has been fixed in CVS; like you, I tripped over it in 0.82 > and tracked it down--but someone else had already fixed it. A > workaround, if you don't want to install from CVS, is to use the old > subplot(211) form instead of subplot(2,1,1). > > Eric > > Abraham Schneider wrote: > >> Hi. I just installed the newest version of matplotlib (0.82), and >> discovered all my subplots were ending on top of each other. After >> going through my code and verifying everything looked okay, I tried a >> simple: >> >> subplot(2, 1, 1); plot(range(0, 10)); subplot(2, 2, 2); plot(range(0, >> 10)) >> >> and still only got one subplot. I went to the matplotlib code, and >> after some prodding, discovered that all the keys for the _seen map >> were exactly the same. Going to the _make_key function revealed that >> my use of subplot (i.e. three seperate arguments), was not working. >> Here is a fix that seems to work for me: >> >> (int _make_key function): >> if iterable(args[0]): >> key = tuple(args[0]), tuple( fixitems(kwargs.items())) >> ## NEW >> elif len(args) > 1: >> key = args, tuple( fixitems(kwargs.items())) >> ## \NEW >> else: >> key = args[0], tuple(fixitems( kwargs.items())) >> >> Abe >> >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by the 'Do More With Dual!' webinar >> happening >> July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual >> core and dual graphics technology at this free one hour event hosted >> by HP, >> AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar >> _______________________________________________ >> Matplotlib-devel mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the 'Do More With Dual!' webinar > happening > July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual > core and dual graphics technology at this free one hour event hosted > by HP, > AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel |
|
From: Eric F. <ef...@ha...> - 2005-07-08 02:20:10
|
Abe, That bug has been fixed in CVS; like you, I tripped over it in 0.82 and tracked it down--but someone else had already fixed it. A workaround, if you don't want to install from CVS, is to use the old subplot(211) form instead of subplot(2,1,1). Eric Abraham Schneider wrote: > Hi. I just installed the newest version of matplotlib (0.82), and > discovered all my subplots were ending on top of each other. After going > through my code and verifying everything looked okay, I tried a simple: > > subplot(2, 1, 1); plot(range(0, 10)); subplot(2, 2, 2); plot(range(0, 10)) > > and still only got one subplot. I went to the matplotlib code, and after > some prodding, discovered that all the keys for the _seen map were > exactly the same. Going to the _make_key function revealed that my use > of subplot (i.e. three seperate arguments), was not working. Here is a > fix that seems to work for me: > > (int _make_key function): > if iterable(args[0]): > key = tuple(args[0]), tuple( fixitems(kwargs.items())) > ## NEW > elif len(args) > 1: > key = args, tuple( fixitems(kwargs.items())) > ## \NEW > else: > key = args[0], tuple(fixitems( kwargs.items())) > > Abe > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the 'Do More With Dual!' webinar > happening > July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual > core and dual graphics technology at this free one hour event hosted by HP, > AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel |
|
From: Abraham S. <ab...@cn...> - 2005-07-08 02:12:11
|
Hi. I just installed the newest version of matplotlib (0.82), and
discovered all my subplots were ending on top of each other. After going
through my code and verifying everything looked okay, I tried a simple:
subplot(2, 1, 1); plot(range(0, 10)); subplot(2, 2, 2); plot(range(0, 10))
and still only got one subplot. I went to the matplotlib code, and after
some prodding, discovered that all the keys for the _seen map were
exactly the same. Going to the _make_key function revealed that my use
of subplot (i.e. three seperate arguments), was not working. Here is a
fix that seems to work for me:
(int _make_key function):
if iterable(args[0]):
key = tuple(args[0]), tuple( fixitems(kwargs.items()))
## NEW
elif len(args) > 1:
key = args, tuple( fixitems(kwargs.items()))
## \NEW
else:
key = args[0], tuple(fixitems( kwargs.items()))
Abe
|
|
From: Eric F. <ef...@ha...> - 2005-07-08 01:32:34
|
John, Attached is the diff against CVS for lines.py, with a fix for the set_xdata/set_ydata bug that Torsten found. The changes are: (0) (Sorry--looks like part of the diff is caused merely by trailing space characters that my editor strips off.) 1) I replaced _masked_x and _masked_y attributes with _x_orig and _y_orig, which hold the inputs to set_data with no changes; they are always used, regardless of whether the inputs are masked or not. This leads to some simplification, and solves the problem Torsten found. The penalty is that if neither x nor y is masked and both are already 1-D numerix float arrays, then both are needlessly stored twice, once in _x_orig/_y_orig, and again in _x and _y. (Actually, this may not be true; I am not sure whether the arrays are duplicated or whether there are merely separate references to the same data arrays. I could figure it out, but I don't want to spend time on that now unless it is deemed urgent.) 2) I made some other changes in set_data to make it simpler and more readable; in particular, using ma.ravel() at the start eliminates several later conditionals and calls to ravel. 3) There seems to have been half-way support for letting either x or y be of length 1, and having it automatically expanded to match the other variable; I completed this support and moved it to near the top of the function. If it is not useful, it can be removed easily with no ill effects. (All it would be good for is making horizontal or vertical lines.) Eric |
|
From: John H. <jdh...@ac...> - 2005-07-07 16:28:07
|
>>>>> "Adrian" == Adrian E Feiguin <afe...@uc...> writes:
Adrian> Hi everybody, I just found your application, and I'm
Adrian> stunned. You've done a great job. I'm the lead developer
Adrian> of another application called SciGraphica
Adrian> (http://scigraphica.sourceforge.net) and GtkExtra, a
Adrian> package of widgets for (among other things) plotting 2d,
Adrian> contour, 3d, and polar plots. SciGraphica is built on top
Adrian> of gtkextra and it's not competing with matplot in the
Adrian> sense that it aims at having a GUI based program ala
Adrian> Microcal Origin, with spreadsheets for editing and
Adrian> manipulating the data. I hope you agree that we can learn
Adrian> from each others experiences with algorithms, etc. This is
Adrian> precisely why I'm contacting you, guys!
Hi Adrian,
Thanks for the kind words. scigraphica looks like an incredible
project; combined with gtkextra it must keep you pretty busy.
Adrian> I have to confess that my contour and 3d plots are pretty
Adrian> "raw" in the sense that the algorithms I use are quite
Adrian> primitive and slow. I basicaly generate a delaunay
Adrian> triangulation and cut the triangles with planes, and draw
Adrian> the resulting polygons. I was wondering if you guys could
Adrian> give me some feedback about a good algorithm for plotting
Adrian> 2d contour plots, or at least, tell me where to look in
Adrian> your code to see if I can learn from it. Whare are the
Adrian> actual engines to plot the pie charts and contours, for
Adrian> instance?
The contouring engine is pure C code and is borrowed from the gist
library; see src/cntr.c. There are some python classes that sit on
top of this to create the graphics objects and labeling, and these are
in lib/matplotlib/contour.py. As far as we are able to determine, the
C code from gist does not have any licensing restrictions, and the
matplotlib contouring routines are all PSF/BSD compatible in their
licenses so you are welcome to borrow them for your own code. There
are many more publicly available routines you can consider since you
have a GPL license; matplotlib has a more permissive license and we
tryu to avoid GPL code for that reason. Most of the contouring
routines we considered, along with the licenses and possible patent
encumbrances, were discussed on the devel list last year in this
thread http://sourceforge.net/mailarchive/message.php?msg_id=9890501 .
As far as the "actual engines" we use to make plots, matplotlib has
several engines it can use (PS, SVG, antigrain, GTK, Cairo, GD, ...)
All of the screenshots were produced with the antigrain renderer, a
C++ library for 2D antialiased rendering with full alpha channel
support (http://antigrain.com). We embed the antigrain rendered
images into a variety of GUI canvases (Tk, GTK, WX, FLTK, Qt) using a
bitmap transfer.
Hope this helps!
JDH
|
|
From: Adrian E. F. <afe...@uc...> - 2005-07-06 23:59:49
|
Hi everybody, I just found your application, and I'm stunned. You've done a great job. I'm the lead developer of another application called SciGraphica (http://scigraphica.sourceforge.net) and GtkExtra, a package of widgets for (among other things) plotting 2d, contour, 3d, and polar plots. SciGraphica is built on top of gtkextra and it's not competing with matplot in the sense that it aims at having a GUI based program ala Microcal Origin, with spreadsheets for editing and manipulating the data. I hope you agree that we can learn from each others experiences with algorithms, etc. This is precisely why I'm contacting you, guys! I have to confess that my contour and 3d plots are pretty "raw" in the sense that the algorithms I use are quite primitive and slow. I basicaly generate a delaunay triangulation and cut the triangles with planes, and draw the resulting polygons. I was wondering if you guys could give me some feedback about a good algorithm for plotting 2d contour plots, or at least, tell me where to look in your code to see if I can learn from it. Whare are the actual engines to plot the pie charts and contours, for instance? I hope you guys don't mind sharing info with me, actually this is one of the reasons for doing OSS. I hope we can enjoy a fruitful communication. All the best, and congratulations again for your project. Saludos, <ADRIAN> PS: If by any chance you feel inclined to trying SG, I suggest you to go directly for the CVS code, since the latest release is not very stable. |
|
From: Fernando P. <Fer...@co...> - 2005-07-06 16:17:29
|
John Hunter wrote: >>>>>>"Fernando" == Fernando Perez <Fer...@co...> writes: > > > Fernando> Stephen Walton wrote: > >> Fernando Perez wrote: > >>> Well, it could be something like $HOME/.tex.cache, where $HOME > >>> can be determined via a routine like the below (this is what > >>> ipython uses to try and guess a sensible value for $HOME): > >> I *like* it. > > Fernando> Though I'd personally vote for matplotlib holding > Fernando> $HOME/.matplotlib/ as a directory, and putting in there > Fernando> a tex.cache dir, the matplotlibrc file, and anything > Fernando> else it may need in the future. > > I am in the process of moving all of matplotlib's config files and > outputs to HOME/.matplotlib. Great! > what I am really after is a simple print >> sys.stderr. Is there > anything wrong with using sys.stderr for this kind of thing, error > mavens? I know when we discussed this many moons ago we converged on > using exceptions and the warnings module everywhere. But now I am a > bit confounded by the inability to make the warnings print pretty > messages that the typical user will read and understand. Or is there > a way to tell warning.warn to just print the error message with no > lineno/traceback info? Dunno, sorry. In ipython, I have a trivial warn() routine which is just a print >> sys.stderr wrapper. I've never used the stdlib's warnings module. Cheers, f |
|
From: John H. <jdh...@ac...> - 2005-07-06 14:04:35
|
>>>>> "Fernando" == Fernando Perez <Fer...@co...> writes:
Fernando> Stephen Walton wrote:
>> Fernando Perez wrote:
>>> Well, it could be something like $HOME/.tex.cache, where $HOME
>>> can be determined via a routine like the below (this is what
>>> ipython uses to try and guess a sensible value for $HOME):
>> I *like* it.
Fernando> Though I'd personally vote for matplotlib holding
Fernando> $HOME/.matplotlib/ as a directory, and putting in there
Fernando> a tex.cache dir, the matplotlibrc file, and anything
Fernando> else it may need in the future.
I am in the process of moving all of matplotlib's config files and
outputs to HOME/.matplotlib.
I want to issue a warning to users if I find a .matplotlibrc file (the
new name is matplotlibrc (no hidden "dot") and the default location is
HOME/.matplotlib/matplotlibrc. As before, you can put an rc file in
the current dir.
I am using warnings.warn to issue the warning
home = get_home()
oldname = os.path.join( home, '.matplotlibrc')
if os.path.exists(oldname):
warnings.warn('Old rc filename "%s" found and ignored; new default rc file name is HOME/.matplotlib/matplotlibrc"'%oldname)
But this results in a warning that looks like this
> python ~/python/projects/matplotlib/examples/subplot_demo.py
/usr/lib/python2.4/site-packages/matplotlib/__init__.py:737: UserWarning: Old rc filename "/home/jdhunter/.matplotlibrc" found and ignored; new default rc file name is HOME/.matplotlib/matplotlibrc"
warnings.warn('Old rc filename "%s" found and ignored; new default rc file name is HOME/.matplotlib/matplotlibrc"'%oldname)
which I find hard to read. I can add a stacklevel=0 argument to warn
which is slightly more legible
> python ~/python/projects/matplotlib/examples/subplot_demo.py
/usr/lib/python2.4/warnings.py:41: UserWarning: Old rc filename "/home/jdhunter/.matplotlibrc" found and ignored; new default rc file name is HOME/.matplotlib/matplotlibrc"
lineno = caller.f_lineno
but still has the annoying "lineno = caller.f_lineno"
what I am really after is a simple print >> sys.stderr. Is there
anything wrong with using sys.stderr for this kind of thing, error
mavens? I know when we discussed this many moons ago we converged on
using exceptions and the warnings module everywhere. But now I am a
bit confounded by the inability to make the warnings print pretty
messages that the typical user will read and understand. Or is there
a way to tell warning.warn to just print the error message with no
lineno/traceback info?
JDH
|
|
From: John H. <jdh...@ac...> - 2005-07-05 16:59:02
|
>>>>> "Tom" == Tom Denniston <tom...@gm...> writes:
Tom> I have been using matplotlib a few days now and think I it is
Tom> great but recently I have gotten hung up on a problem
Tom> plotting negative numbers.
Tom> I am trying to plot data where the y values are all negative.
Tom> When I do this I get the No positive data to plot error. I
Tom> have tracked it down to the following two line is
Tom> /matplotlib/ticker.py: if minpos<=0: raise RuntimeError('No
Tom> positive data to plot')
This should only be occurring if you have log scaling set. Could you
get a fresh copy of matplotlib CVS and see if you can replicate the
bug. And if so, please post a script that exposes it.
Thanks,
JDH
|
|
From: Marcin W. <wo...@un...> - 2005-07-01 11:03:05
|
Matt Newville wrote: > Marcin, > > I think it's a known feature of the Toolbars that they use a > Frame not a Panel, at least for the wx backend. It's hard for Usually they use Frame, but they can also work with another Windows. > me to get excited about this as I don't use the Toolbars, but if > you can send a patch that makes them work for a Panel, that's > fine with me. Toolbars work fine, the only problem was with the parent of FileDialogs. Very simple patch is attached. > >> I haven't solved the second problem yet. It can be seen on >> simple_plot.py.. When I decrease window's size plot doesn't >> shrink like in GTK backend, and only part of the plot is >> visible. It used to work properly in older wx and MPL >> versions. > > You didn't specify an OS, which probably means linux ;). I yes :-) Marcin --=20 Marcin Wojdyr | http://www.unipress.waw.pl/~wojdyr |
|
From: Matt N. <new...@ca...> - 2005-06-30 18:44:09
|
Marcin, > I have wx app with MPL plots embedded. There are two problems > I noticed after upgrading wxPython to 2.6.1 and MPL to current > CVS: When toolbar (i.e. NavigationToolbar2WX) has parent > different then wx.Frame, (wx.Panel in my case), it crashes > when clicking "Save" button. The problem is that wx.FileDialog > has to have top level window as its parent. The workaround is > eg. to set toolbar._parent=None (a dialog created with None > parent window is given the application's top level window as > parent) I think it's a known feature of the Toolbars that they use a Frame not a Panel, at least for the wx backend. It's hard for me to get excited about this as I don't use the Toolbars, but if you can send a patch that makes them work for a Panel, that's fine with me. > I haven't solved the second problem yet. It can be seen on > simple_plot.py.. When I decrease window's size plot doesn't > shrink like in GTK backend, and only part of the plot is > visible. It used to work properly in older wx and MPL > versions. You didn't specify an OS, which probably means linux ;). I don't see this problem on Windows or Mac, but haven't installed wxPython 2.6.1 on linux yet. --Matt |
|
From: Marcin W. <wo...@un...> - 2005-06-29 16:40:13
|
Hi, I have wx app with MPL plots embedded. There are two problems I noticed after upgrading wxPython to 2.6.1 and MPL to current CVS: When toolbar (i.e. NavigationToolbar2WX) has parent different then wx.Fra= me, (wx.Panel in my case), it crashes when clicking "Save" button. The problem is that wx.FileDialog has to have top level window as its par= ent. The workaround is eg. to set toolbar._parent=3DNone (a dialog created wi= th None parent window is given the application's top level window as parent) I haven't solved the second problem yet. It can be seen on simple_plot.py= . When I decrease window's size plot doesn't shrink like in GTK backend, and only part of the plot is visible. It used to work properly in older wx and MPL versions. Marcin --=20 Marcin Wojdyr | http://www.unipress.waw.pl/~wojdyr |
|
From: Tom D. <tom...@gm...> - 2005-06-24 15:09:59
|
I have been using matplotlib a few days now and think I it is great
but recently I have gotten hung up on a problem plotting negative
numbers.
I am trying to plot data where the y values are all negative. When I
do this I get the No positive data to plot error. I have tracked it
down to the following two line is
/matplotlib/ticker.py:
if minpos<=3D0:=20
raise RuntimeError('No positive data to plot')
It looks like for some reason Matplotlib wants positive values when it
does the axis scaling. I commented out the two lines and it works
like a charm now. My question is, do these two lines of code serve a
useful purpose. Does commenting them out break something else or is
this a change that can be incorporated back into the matplotlib
source?
Full stack trace=20
---> 33 splot.plot(x1, y1, "g", x2, y2, "r")
/home/tdennist/lib/python/matplotlib/axes.py in plot(self, *args, **kwargs)
2524 lines.append(line)
2525 lines =3D [line for line in lines] # consume the generator
-> 2526 self.autoscale_view()
2527 return lines
2528
/home/tdennist/lib/python/matplotlib/axes.py in autoscale_view(self)
783
784 locator =3D self.yaxis.get_major_locator()
--> 785 self.set_ylim(locator.autoscale())
786
787
/home/tdennist/lib/python/matplotlib/ticker.py in autoscale(self)
819
820 if minpos<=3D0:
--> 821 raise RuntimeError('No positive data to plot')
822 if vmin<=3D0:
823 vmin =3D minpos
RuntimeError: No positive data to plot
In [50]: exampleReturns.logHistogramPlot([1,2,3,4,0], 100)
|
|
From: Nicholas Y. <su...@su...> - 2005-06-24 10:52:10
|
On Thu, 2005-06-23 at 10:58 -0600, Fernando Perez wrote: > Nicholas Young wrote: > > On Wed, 2005-06-22 at 11:45 -0600, Fernando Perez wrote: > > > >>os.environ['TEXMFOUTPUT'] = '/some/path' > > > > > > According to the online docs > > (http://docs.python.org/lib/os-procinfo.html) setting os.environ isn't > > safe/available for all platforms. You can use the subprocess module to > > set the environment of a subprocess under python 2.4 but I don't think > > there's a simple way to do this and capture the output for earlier > > versions. > > Well, after reading that I get that os.environ _is_ writable everywhere, it's > just that it may leak memory in OSX/BSD. What's not always available is the > putenv() call, but python will find its way around it if needed. To quote "If putenv() is not provided, this mapping may be passed to the appropriate process-creation functions to cause child processes to use a modified environment.". To me this implies that you have to pass os.environ to a process-creation function supporting the env keyword (os.execve, etc.) none of which seem to support capturing output. On the other hand does anyone actually run mpl on a platform which doesn't support putenv? > Since this would be a once-only call, I think that leaking a few bytes is an > acceptable price to pay to prevent a crash if the user happens to be > positioned on a non-writable dir. After reading an online copy of the freebsd man putenv it actually reads "Successive calls to setenv() or putenv() assigning a differently sized value to the same name will result in a memory leak." so setting this once wouldn't be a problem. So I was wrong and setting os.environ seems reasonable in this case - but it seems sensible to be aware of the potential for causing problems if anyone trys to get mpl working on an odd platform. Nick |
|
From: Fernando P. <Fer...@co...> - 2005-06-23 16:58:06
|
Nicholas Young wrote: > On Wed, 2005-06-22 at 11:45 -0600, Fernando Perez wrote: > >>os.environ['TEXMFOUTPUT'] = '/some/path' > > > According to the online docs > (http://docs.python.org/lib/os-procinfo.html) setting os.environ isn't > safe/available for all platforms. You can use the subprocess module to > set the environment of a subprocess under python 2.4 but I don't think > there's a simple way to do this and capture the output for earlier > versions. Well, after reading that I get that os.environ _is_ writable everywhere, it's just that it may leak memory in OSX/BSD. What's not always available is the putenv() call, but python will find its way around it if needed. Since this would be a once-only call, I think that leaking a few bytes is an acceptable price to pay to prevent a crash if the user happens to be positioned on a non-writable dir. Cheers, f |
|
From: Stefan K. <pon...@ya...> - 2005-06-23 15:21:45
|
Sorry for the long post, 2 things..
The first is that I am getting a compiler error on Solaris. This is
installing v0.80, I was wondering if anyone had seen this...
/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:324:
error: `wmemcmp' undeclared (first use this function)
/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:324:
error: (Each undeclared identifier is reported only once for each
function it
appears in.)
/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:
In static member function `static const wchar_t*
std::char_traits<wchar_t>::find(const wchar_t*, size_t, const
wchar_t&)':
/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:332:
error: invalid conversion from `const wchar_t*' to `wchar_t*'
/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:332:
error: initializing argument 1 of `wchar_t* std::wmemchr(wchar_t*,
wchar_t,
size_t)'
/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:
In static member function `static wchar_t*
std::char_traits<wchar_t>::move(wchar_t*, const wchar_t*, size_t)':
/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:336:
error: `wmemmove' undeclared (first use this function)
/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:
In static member function `static wchar_t*
std::char_traits<wchar_t>::copy(wchar_t*, const wchar_t*, size_t)':
/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:340:
error: `wmemcpy' undeclared (first use this function)
/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:
In static member function `static wchar_t*
std::char_traits<wchar_t>::assign(wchar_t*, size_t, wchar_t)':
/work/net-local-b/sparc-sun-solaris2.8/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/../../../../include/c++/3.4.2/bits/char_traits.h:344:
error: `wmemset' undeclared (first use this function)
./CXX/Extensions.hxx: In constructor
`Py::PythonExtension<T>::PythonExtension()
[with T = Py::ExtensionModuleBasePtr]':
CXX/cxx_extensions.cxx:92: instantiated from here
./CXX/Extensions.hxx:472: warning: right-hand operand of comma has no
effect
error: command 'gcc' failed with exit status 1
The second thing is that I wrote a speedometer widget. It is basically
a half pie chart with 3 color coded wedges, tick marks on the dial and
a needle that positions between 1 and 100 ( the value passed ). It's a
quick job ( esp. the mangled borrow from the arrow drawing code :)
designed to make small dial graphics for 'dashboard' type UIs. But
turns out I will not need it or work on it, so I'm sending it out there
for the community.
S
here is the dial.py listing..
#!/usr/bin/env python
"""
Make a dial
"""
from pylab import *
from matplotlib.patches import Patch, Rectangle, Circle, Polygon,
Wedge,
Shadow, bbox_artist
from math import *
import os
# map to radian
degree_map = {}
degrees = range( 270, 360 ) + range( 0, 91 )
i = 0
for degree in degrees:
degree_map[i] = degree
i += 1
image_counter = 0
def make_dial( outdir, value ):
global image_counter
filename = 'dial_%s' % image_counter
image_counter += 1
# scale to 180 and map to radians
value = value * 1.8
degree = degree_map[int(value)]
# make a square figure and axes
fig = figure(figsize=(1,.5), edgecolor='white')
ax = axes( [0, 0, 1, 2])
ax.set_frame_on( False )
ax.xaxis._visible = False
ax.yaxis._visible = False
s = Circle( (.5, 0), .5, facecolor='black' )
ax.add_patch( s )
if value <= 180 and value >= 130 :
color = 'green'
else:
color = 'gray'
w = Wedge((.5,0), .47, 0, 50, facecolor=color, edgecolor=color)
ax.add_patch( w )
if value < 130 and value >= 50:
color = 'yellow'
else:
color = 'gray'
w = Wedge((.5,0), .47, 50, 130, facecolor=color, edgecolor=color)
ax.add_patch( w )
if value < 50:
color = 'red'
else:
color = 'gray'
w = Wedge((.5,0), .47, 130, 180, facecolor=color, edgecolor=color)
ax.add_patch( w )
def _mark( degree, r1=.35, r2=.4, width=.01, color='white' ):
x1 = sin( (degree*(pi/180))) * r1
y1 = cos( (degree*(pi/180))) * r1
x2 = sin( (degree*(pi/180))) * r2
y2 = cos( (degree*(pi/180))) *r2
x1 += .009
x2 += .009
dx = x2-x1
dy = y2-y1
width = width
arrow = array( [
[ 0.0, 0.2 ],
[ 0.0, -0.2],
[ 0.8, -0.2 ],
[ 0.8, 0.2 ] ] )
L = sqrt(dx**2+dy**2)
arrow[:,0] *= L
arrow[:,1] *= width
cx = float(dx)/L
sx = float(dy)/L
M = array( [ [ cx, sx],[ -sx, cx ] ] )
verts = matrixmultiply( arrow, M ) + [x1+.5,y1]
s = Polygon( [ tuple(t) for t in verts ], facecolor=color,
edgecolor=color )
ax.add_patch( s )
_mark( 0 ) #not sure why, but it likes the extra mark call
_mark( 0 )
_mark( 20 )
_mark( 40 )
_mark( 60 )
_mark( 80 )
_mark( 340 )
_mark( 320 )
_mark( 300 )
_mark( 280 )
if value < 50:
color = 'white'
else:
color = 'black'
_mark( degree, 0, .48, .1, color )
fullpath = outdir + os.sep + filename
savefig( fullpath, dpi=30)
return filename
if __name__ == '__main__':
make_dial( '.', 100 )
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
|
|
From: Nicholas Y. <su...@su...> - 2005-06-23 10:58:06
|
On Wed, 2005-06-22 at 11:45 -0600, Fernando Perez wrote: > os.environ['TEXMFOUTPUT'] = '/some/path' According to the online docs (http://docs.python.org/lib/os-procinfo.html) setting os.environ isn't safe/available for all platforms. You can use the subprocess module to set the environment of a subprocess under python 2.4 but I don't think there's a simple way to do this and capture the output for earlier versions. Nick |
|
From: Darren D. <dd...@co...> - 2005-06-22 22:42:20
|
On Wednesday 22 June 2005 06:35 pm, Fernando Perez wrote: > Stephen Walton wrote: > > Fernando Perez wrote: > >>Well, it could be something like $HOME/.tex.cache, where $HOME can be > >>determined via a routine like the below (this is what ipython uses to > >>try and guess a sensible value for $HOME): > > > > I *like* it. > > Though I'd personally vote for matplotlib holding $HOME/.matplotlib/ as a > directory, and putting in there a tex.cache dir, the matplotlibrc file, and > anything else it may need in the future. I second that notion. In fact, I have been meaning to suggest this on the list for some time now. Thank for reminding me. > I *really* don't like the idea that matplotlib will begin to put a bunch of > differently named things under $HOME with various .foo names. Ipython also > started with .ipythonrc, and I quickly moved to an .ipython/ directory, > where I stuff anything I need. It's future-proof, clean, and gives an easy > way for users to clean up if needed, without having to guess 'how many dot > files/directories does this thing create'? > > So if you were to ask for my opinion, I'd vote +100 on matplotlib moving to > a single directory for holding *ALL* user and configuration data, which > would default to $HOME/.matplotlib, and which could be overridden if the > $MATPLOTLIBDIR environment variable is defined. That's exactly how ipython > works, so it must be the perfect solution :) +101 Darren |