← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2624: plot.py: added `legendPosition` and `legendPositionSecondary` so we can decide

 

------------------------------------------------------------
revno: 2624
committer: Janek Kozicki <cosurgi@xxxxxxxxxx>
branch nick: yade
timestamp: Tue 2010-12-21 21:37:08 +0100
message:
  plot.py: added `legendPosition` and `legendPositionSecondary` so we can decide
  where the legend should be placed, by default it is 'upper left' and 'upper right'
  
  fix missing header in KinematicEngines.cpp
modified:
  pkg/common/KinematicEngines.cpp
  py/plot.py


--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'pkg/common/KinematicEngines.cpp'
--- pkg/common/KinematicEngines.cpp	2010-12-21 12:41:02 +0000
+++ pkg/common/KinematicEngines.cpp	2010-12-21 20:37:08 +0000
@@ -1,4 +1,5 @@
 
+#include<yade/core/Scene.hpp>
 #include<yade/pkg/common/KinematicEngines.hpp>
 #include<yade/pkg/dem/Shop.hpp>
 #include<yade/lib/smoothing/LinearInterpolate.hpp>

=== modified file 'py/plot.py'
--- py/plot.py	2010-12-08 15:20:55 +0000
+++ py/plot.py	2010-12-21 20:37:08 +0000
@@ -43,6 +43,10 @@
 xylabels={}
 "Dictionary of 2-tuples specifying (xlabel,ylabel) for respective plots; if either of them is None, the default auto-generated title is used."
 
+legendPosition='upper left'
+"Placement of the legend on the plot"
+legendPositionSecondary='upper right'
+"Placement of the scondary legend on the plot"
 
 live=True if yade.runtime.hasDisplay else False
 "Enable/disable live plot updating. Disabled by default for now, since it has a few rough edges."
@@ -183,7 +187,7 @@
 			scatter=pylab.scatter(scatterPt[0] if not math.isnan(scatterPt[0]) else 0,scatterPt[1] if not math.isnan(scatterPt[1]) else 0,color=line.get_color())
 			currLineRefs.append(LineRef(line,scatter,data[pStrip],data[d[0]]))
 		# create the legend
-		l=pylab.legend([xlateLabel(_p[0]) for _p in plots_p_y1],loc=('upper left' if len(plots_p_y2)>0 else 'best'))
+		l=pylab.legend([xlateLabel(_p[0]) for _p in plots_p_y1],loc=(legendPosition if len(plots_p_y2)>0 else 'best'))
 		if hasattr(l,'draggable'): l.draggable(True)
 		pylab.ylabel((', '.join([xlateLabel(_p[0]) for _p in plots_p_y1])) if p not in xylabels or not xylabels[p][1] else xylabels[p][1])
 		pylab.xlabel(xlateLabel(pStrip) if (p not in xylabels or not xylabels[p][0]) else xylabels[p][0])
@@ -203,7 +207,7 @@
 				scatter=pylab.scatter(scatterPt[0] if not math.isnan(scatterPt[0]) else 0,scatterPt[1] if not math.isnan(scatterPt[1]) else 0,color=line.get_color())
 				currLineRefs.append(LineRef(line,scatter,data[pStrip],data[d[0]]))
 			# legend
-			l=pylab.legend([xlateLabel(_p[0]) for _p in plots_p_y2],loc='upper right')
+			l=pylab.legend([xlateLabel(_p[0]) for _p in plots_p_y2],loc=legendPositionSecondary)
 			if hasattr(l,'draggable'): l.draggable(True)
 			pylab.rcParams['lines.color']=origLinesColor
 			pylab.ylabel((', '.join([xlateLabel(_p[0]) for _p in plots_p_y2])) if p not in xylabels or len(xylabels[p])<3 or not xylabels[p][2] else xylabels[p][2])


Follow ups