Hi, As already discussed some time ago on the scipy-user mailing list we have compiled a list of issues/bugs/wishes concerning scipy.xplt. The notes below are written in Restructured text and the html version (+example files) can be found at http://www.physik.tu-dresden.de/~baecker/tmp/xplt/xplt_issues.html Best, Jan Braun and Arnd Baecker ############################ .. -*- mode: rst -*- =========== Xplt issues =========== Remark ahead ============ As already discussed some time ago on this mailing list we have compiled a list of issues/bugs/wishes concerning xplt. This text is written in Restructured text (`ReSt <http://docutils.sourceforge.net/rst.html>`_ and the html version can be found at `xplt_issues.html <http://www.physik.tu-dresden.de/~baecker/tmp/xplt/xplt_issues.html>`_). This text is structured in three parts: 1. Differences between Windows/Linux 2. Platform independent problems 3. A wishlist for improvements of the present behavior .. contents:: PART I, PORTING PROBLEMS ======================== Plotting one point ------------------ Plotting one point using xplt.plg() leads to differing results under Windows/Linux depending on the method used: 1. using plg with 1-element arrays: this works fine under Windows, where xplt/gist plots a single point at the specified position. Under Linux no point is obtained (if one uses standard parameters for plg) and you won't see any graphical output. 2. To get xplt/Linux plotting a single point you need to plot a line from the point to itself. Alternatively, one can disable the plotting of lines and change the marker. Try the example `plot_single_points.py <plot_single_points.py>`_ on Windows and Linux to see this. :: from scipy.xplt import * x=0.5 y=1.0 window() pldefault(marks=0) # plotting a line from/to the same point plg(x*ones(2),y*ones(2),type="dot",marks=0,msize=5) # plotting a single point plg([1],[1],marks=0,type=0,marker=1,msize=5) Pause() and Windows ------------------- The pause() command does not work under Windows. This code :: from scipy.xplt import pause for x in arange(40): print x pause( 100 ) should print the numbers from 0 to 39 but will stop right after printing 0 if started under windows. Example: `pause_windows.py <pause_windows.py>`_. Undefined background colors --------------------------- It seems that the background color of plots depends on the window manager. So some people happily plot white symbols on their grey background, whereas with a different window manager one can end up with white symbols on a white background. It would be a good to force a default background color in the plotting template. PART II, GENERAL PLOTTING ISSUES ================================ Labeling and titles ------------------- Without defined limits() the labels given with x-/ylabel are lost with every scale change. Using limits() preserves the scale and labels. It even brings back labels, that were lost after a rescale. Titles however, are only lost by using fma(). (Applies to titles defined by pl-/title.) :: from scipy.xplt import * window( wait=1 ) xlabel( "xlabel" ) # creates the xlabel x=arange( 100 ) plg( x, x ) # destroys the label limits( 0, 75, 0, 75 ) # label reappears plg( x, x ) # label is preserved by limits fma() plg( x, 0.5*x ) # labels are lost now # although the limits are preserved # a new call to limits() won't bring it back xlabel( "xlabel" ) # recreating label till next fma() plg( x, x ) # labels preserved by old limits It is not possible to get around multiple label/title definitions even using limits(). It would be useful to have these commands installing labels and titles as permanent as the limits used. Example: `labeling.py <labeling.py>`_. Missing axes in empty Windows and corrupted mouse input (animate,fma) --------------------------------------------------------------------- By default xplt knows two coordinate systems for mouse input. By setting limits() or plotting into a window the default coordinate system is specified by the visible part of the axes. In interactive simulations it is often necessary that a user selects coordinates using the mouse. All this works fine most of the time, however, problems occur using the animate() mode or in new windows. Switching buffers with fma() lets xplt loose the frame of reference for mouse input. In fact you will get some coordinates between zero and one. If you don't want to use normalized device coordinates you have to plot after the fma() or use the axes() command. Supplying limits wont help. animate() mode even has another interesting behavior in conjunction with the mouse() command. If you advance a frame, take mouse input and draw _one_ graph, the axes are adjusted to the full length, but only a part of the graph is shown. :: from scipy.xplt import * window( wait=1 ) x=arange( 100 ) animate( 1 ) plg( .5*x,x) fma() m=mouse( -1, 1 ) # mouse input print "used c. system: ", m[8] print " position of mouse: ( ", m[3], ", ", m[4], ")" plg( .5*x,x) fma() # only part of the plot is shown # wont occur if more than one graph is plotted m=mouse(-1,1) print "used c. system: ", m[8] # uses "wrong" coordinate system "0" print " position of mouse: ( ", m[3], ", ", m[4], ")" plg(x,x) # we need to plot something __without__ # advancing a frame (no visible change) m=mouse(-1,1) print "used c. system: ", m[8] # now we get the correct c. system "1" print " position of mouse: ( ", m[3], ", ", m[4], ")" This example is available as `mouse_coords.py <mouse_coords.py>`_. Plot symbols ------------ The symbols are not properly centered to the point they correspond to. This seems to be just a vertical problem. :: x=arange(0.0,1.01,0.5) plg(x*x,x,marker=2,type=0,msize=4,color="red") plg(x*x,x,marker=1,type=0,msize=4) plg(x*x,x,marker=3,type=0,msize=4,color="green") plg(x*x,x,marker=4,type=0,msize=4,) The different colors are just for illustration and the effect is not size-dependent, for an example see `centered_plot_symbols.py <centered_plot_symbols.py>`_. Memory errors with arrays ------------------------- :: x=arange(0.0,1.0,0.1) y=2 plg(y,2) This code results in the misleading message (??) :: MemoryError Especially beginners have difficulties to correct the code. A more helpful error message would be better as it should be easy to check that the arrays are real and of the same length. Even floats (not arrays) should be allowed as input, IM-HO. Fast repeated mouse events -------------------------- Fast clicking on plot windows results in zoom/unzoom events even if mouse input is desired. This may lead to the impossibility to restore the original viewport. While it is possible to disable zoom with zoom_factor( 1 ), it would be helpful to deactivate the movement of the viewport, PART III, Wishlist items ======================== Arbitrary size windows under X ------------------------------- The only possibility to influence the size of windows is the dpi parameter, which lets one choose between 75 and 100 dpi. It would be nice to define different window-sizes for display. Positioning of windows (x-geometry) ----------------------------------- In addition to the preceeding point it would be nice to define a window-position. At the moment you have to rely on the window manager facilities, so you can't assure useful positions of multiple plot windows. Several windows and Mouse-clicks -------------------------------- :: from scipy.xplt import * x=arange( 0.0, 1.0, 0.1 ) window( 0 ) plg( x, x ) window( 1 ) plg( x*x, x ) while 1: m=mouse( 1, 1, "Click with the mouse, finish with right-click" ) if m[9]==3: break Clicking in window 0 one gets the last coordinates clicked in window 1, but no meaningful answer. Would it be possible to - return the correct click-coordinates regardless of the "active" window - add mouse[11] as return parameter which contains the window number in which the user clicked - supply a non-blocking function to report waiting mouse events Minor ----- Under X11: - xlabel too close to the graph - ylabel too close to the left border
participants (1)
-
Arnd Baecker