Re: [Matplotlib-users] How by clicking an axes label open a dialog?
On Thursday September 9 2010 20:33:03 sa6113 wrote: I want to use backendQtAgg inorder to imbed plot dialog into basic dialog and by clicking the labels open plot option. I couldn't use 'motion_notify_event' because the event only handles into plot area not in canvas area!!! anybody knows? Hi, maybe your problem was solved meanwhile, but if not I've got an idea about it. I think you have to adapt the framework used in the widgets.py defining the class CheckButtons. There one connects the button_press_event to a method _clicked and in this method it is checked wheter or not the click was inside the area associated with the label t.get_window_extent().contains(event.x, event.y) I admit my late reply, but maybe it is useful anyway. Kind regards, Matthias -- Increase Visibility of Your 3D Game App Earn a Chance To Win $500! Tap into the largest installed PC base get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] adding a number of minor tick marks between major tick marks feature
On Monday November 29 2010 22:01:29 Matthew W. Priddy wrote: Matplotlib developers, I really like using matplotlib to create quality plots, and it seems to have an option for just about everything. However, one thing that is not easy to change is the location of minor tick marks. To set major tick mark locations, one can simply use the xticks command. And now we can atleast turn on the minor tick marks with the minorticks_on() command. But, is there any way to implement something similar to xticks for minor tick marks? Even better would be a feature that allowed the user to simply specify the number of minor tick marks that are evenly spaced between the major tick marks? Hi Matthew, one thing, which should work is the following. If you want to set the positions of minor ticks of an axes 'ax', you can use ax.set_xticks([0.02, 0.04, 0.06, 0.08, 0.1], minor=True) but I'm not an expert and I'm not sure if something like you mentioned is already supported (namely providing the number of minor tick marks). Kind regards, Matthias -- Increase Visibility of Your 3D Game App Earn a Chance To Win $500! Tap into the largest installed PC base get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] problem / bug with LogLocator in rev8732
On Thursday October 7 2010 12:06:26 Matthias Michler wrote: Hello list, I run into trouble with the resent svn version using logarithmic scaling as before. This is probably due to the changes from rev 8730 to 8732, where in the ticker,py the line ticklocs = self._transform. ... was added. Running my program I get the following AttributeError: File /scratch/michler/SOFT/lib/python2.6/site- packages/matplotlib/ticker.py, line 1272, in __call__ ticklocs = self._transform.inverted().transform(decades) AttributeError: LogLocator instance has no attribute '_transform' Did I miss anything or is this new feature in an unstable state? Hello list, I would like to propose the attached patch for the error I encountered recently. Could anybody check this, please? Kind regards and thanks in advance, Matthias Index: lib/matplotlib/ticker.py === --- lib/matplotlib/ticker.py (revision 8732) +++ lib/matplotlib/ticker.py (working copy) @@ -1269,7 +1269,7 @@ decades = np.arange(math.floor(vmin), math.ceil(vmax)+stride, stride) -ticklocs = self._transform.inverted().transform(decades) +ticklocs = self.axis.get_transform().inverted().transform(decades) if len(subs) 1 or (len(subs == 1) and subs[0] != 1.0): ticklocs = np.ravel(np.outer(subs, ticklocs)) -- Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today. http://p.sf.net/sfu/beautyoftheweb___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] problem / bug with LogLocator in rev8732
Hello list, I run into trouble with the resent svn version using logarithmic scaling as before. This is probably due to the changes from rev 8730 to 8732, where in the ticker,py the line ticklocs = self._transform. ... was added. Running my program I get the following AttributeError: File /scratch/michler/SOFT/lib/python2.6/site- packages/matplotlib/ticker.py, line 1272, in __call__ ticklocs = self._transform.inverted().transform(decades) AttributeError: LogLocator instance has no attribute '_transform' Did I miss anything or is this new feature in an unstable state? Kind regards, Matthias -- Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today. http://p.sf.net/sfu/beautyoftheweb ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Pie Charts, How to control pie chart size in figure?
On Tuesday August 10 2010 20:31:02 Michael Waters wrote: Hi, I am making a simple pie chart that needs to be small ~3x3 inches. The problem I am having is that the text labels get pushed out side the figure. Is there anyway to make the plot smaller relative to the figure size? Here is my code and the resulting plot: Hi Michael, If you reduce the axes in size the pie chart will be reduced as well, so maybe something like ax = axes([0.25, 0.25, 0.5, 0.5]) is all you need to do. I attached the resulting picture for your interest. Kind regards, Matthias attachment: GSRA_pie_revisited.png-- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Hz to KHz
On Monday July 26 2010 18:23:29 Waléria Antunes David wrote: Hello all, I need to format the values of graphic to KHz.my values are in Hz see at idle python it displays the values as: 3000 3050 3100 3400 , but I need to go where it will be displayed KHz: 3.0 3.1 can someone help me? Hi, I'm not sure, but for me it sounds like the EngFormatter should solve your problem. It's a pitty it seems to be not documented at all, but the following example illustrates its usage: http://matplotlib.sourceforge.net/examples/api/engineering_formatter.html Maybe you can give it a try. Kind regards, Matthias -- The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] share axis and rotate subplot
On Thursday July 29 2010 12:05:24 Bala subramanian wrote: Friends, I wrote a small script to plot a data and its pdf in single figure but as two subplots. 1) However i want to share xaxis of ax2 (subplot 122) with the y axis of ax1 (subplot 121). What function should i use do that. I tried sharex and sharey but i am not gettting what i want. 2) Is there any possiblity to one of the subplot for instance i want to rotate ax2 by 90. #!/usr/bin/env python import matplotlib.pyplot as plt import numpy as np import matplotlib.mlab as mlb data1=np.loadtxt('test.rms',usecols=(1,)) fig=plt.figure() ax1=fig.add_subplot(121) ax2=fig.add_subplot(122) ax1.plot(data1) mu,sigma=np.mean(data1),np.std(data1) n, bins, patches = ax2.hist(data1, bins=25, normed=1, facecolor='green', alpha=0.75,visible=False) y = mlb.normpdf( bins, mu, sigma) l = ax2.plot(bins,y,'-',linewidth=1.2) plt.show() Hi Bala, I attached a small stand-alone example, which illustrates two ways of showing data and its pdf sharing one axis. Maybe this can serve as a starting point for you to solve the problem or you can describe in more detail what is missing. Kind regards, Matthias import numpy as np import matplotlib.pyplot as plt # generate some random data time = np.arange(1000) data = np.random.uniform(size=1000) # generate histogram of data hist, bin_edges = np.histogram(data) # 2 subplots sharing x-axis (- data values) plt.figure(1) ax1 = plt.subplot(211) ax1.set_xlabel(binned data) ax1.set_ylabel(freqency of binned data) ax1.plot(0.5*(bin_edges[:-1]+bin_edges[1:]), hist) ax1.set_ylim(0, max(hist)) ax2 = plt.subplot(212, sharex=ax1) ax2.set_xlabel(data) ax2.set_ylabel(time) ax2.plot(data, time) # 2 subplots sharing y-axis (- data values) plt.figure(2) ax3 = plt.subplot(121) ax2.set_xlabel(time) ax3.set_ylabel(data) ax3.plot(time, data) ax4 = plt.subplot(122, sharey=ax3) ax4.set_ylabel(binned data) ax4.set_xlabel(freqency of binned data) ax4.plot(hist, 0.5*(bin_edges[:-1]+bin_edges[1:])) ax4.set_xlim(0, max(hist)) plt.show() -- The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] ValueError
On Friday July 9 2010 00:06:05 Shir J. Livne wrote: Hello, I keep getting the error ValueError: Need more than 1 value to unpack every time I try to use the line ax.plot_wireframe(myArray[:,0], myArray[:,1], myArray[:,2]) What does that error mean? Hi Shir, I think you used 1d-arrays for myArray[:, i] and the plot_wireframe method expects 2d-arrays for x, y and z, respectively. Inside the plot_wireframe method the shape of Z is transformed into number of rows and columns: rows, cols = Z.shape and that is the point where you get the ValueError, because Z.shape is only one element. You may also want to look at the examples: http://matplotlib.sourceforge.net/examples/mplot3d/wire3d_animation_demo.html http://matplotlib.sourceforge.net/examples/mplot3d/wire3d_demo.html If this doesn't help, it would be useful if you would set up a small stand- alone example illustrating your problem with some simple data with the shape of myArray. Kind regards, Matthias -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to plot the empirical cdf of an array?
On Friday July 9 2010 06:02:58 per freem wrote: How can I plot the empirical CDF of an array of numbers in matplotlib in Python? I'm looking for the cdf analog of pylab's hist function. One thing I can think of is: from scipy.stats import cumfreq a = array([...]) # my array of numbers num_bins = 20 b = cumfreq(a, num_bins) plt.plot(b) Is that correct though? Is there an easier/better way? Hi, I would use pyplot.hist to produce a histogram with a bar for each bin. By use of the keyword argument 'cumulative' you can select cumulative frequency distribution instead of density. Kind regards, Matthias -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to remove a part of the legend ?
On Wednesday, June 30, 2010 06:24:12 pm Philippe Crave wrote: Hello, I have a subplot with 4 lines. I display the legend. I can remove a line easily with something like del(self.ax.lines[n]). But how can I remove the line in the legend ? I found that I can remove all the lines, add news ones, but all the lines (new and deleted) remain in the legend. Hi Philippe, I think you simply can set up a new legend replacing the old one. I attached an example script of that. Kind regards, Matthias import numpy as np from matplotlib import pyplot as plt x = np.linspace(0.0, 2*np.pi, 100) plt.ion() ax = plt.gca() ax.plot(x, +np.sin(x), label='sin(x)') ax.plot(x, +np.cos(x), label='cos(x)') ax.plot(x, -np.sin(x), label='-sin(x)') ax.plot(x, -np.cos(x), label='-cos(x)') plt.legend() raw_input(press Enter to continue - ) # remove some lines ax.lines.pop(-1) ax.lines.pop(2) # set up a new legend plt.legend() plt.ioff() plt.show() -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib in interactive mode from a script
On Tuesday, June 29, 2010 03:32:00 pm ninjasmith wrote: hi there, I've got a bit stuck with running matplotlib in interactive mode. maybe what I want to do can't be done easily. want I want is a simple python script which I can run with a file argument. this will then create some plots. the script will wait for user input (via sys.stdin.readline()), use the input to adjust a threshold and replot my plots. after the user is satisfied with the thresholds the script exit the loop and will perform other processing. Basically I'm trying to get a simple interactive program with plots but without having use wxpython or simliar I have been trying to test the potting part of this. I have successfully set interactive mode on and from the python interpreter I can plot and I see my plots and updates to them without needing to use pyplot.show(). when I run the same scripts by using 'python scriptname.py' I don't see the plots unless I use pyplot.show(). my simple test script is as follows #test interactive matplotlib plotting import numpy as np import sys import matplotlib.pylab as pyp a=np.array([0,4,5,5,3,4,5]) pyp.figure() pyp.plot(a) #pyp.show() input=sys.stdin.readline() pyp.xlabel('my xlabel %s' %input) input=sys.stdin.readline() any help much appreciated Hi, I think what you are after is the interactive mode of matplotlib. You can turn is on by ion and redraw the current figure using draw. In ipythons pylab mode this is done implicit. I attached some example lines which guide you to the right direction. I'm not sure why I need two draws in my attached script, but at least it seems to do the job. For more infos you may visit: http://matplotlib.sourceforge.net/users/shell.html#controlling-interactive- updating Kind regards, Matthias import numpy as np import sys import matplotlib.pylab as pyp a = np.array([0, 4, 5, 5, 3, 4, 5]) pyp.ion() pyp.figure() pyp.plot(a) pyp.draw() pyp.draw() input = sys.stdin.readline() print input 1 : %s % (input) pyp.xlabel('my xlabel %s' % input) pyp.draw() pyp.draw() input = sys.stdin.readline() print input 2 : %s % (input) pyp.ioff() pyp.show() -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] problem with RectangleSelector
On Monday, June 21, 2010 06:30:04 pm Eric Firing wrote: On 06/21/2010 06:10 AM, Matthias Michler wrote: Hello list, I'm encountering a strange problem with the RectangleSelector using the latest version of svn. Namely it doesn't work if it wasn't initialized as RS = RectangleSelector(...) but using RectangleSelector(...) in my script. I modified the example rectangle_selector.py from the folder examples/widgets to illustrate my observation. Can anybody reproduce my findings or even explain what is going on? If you don't keep a reference to the RectangleSelector object, it vanishes--it is garbage-collected. Eric Hi Eric, thanks for your reply. That sounds reasonable, but I'm still confused. With the matplotlib release 0.99.1.1 the RectangleSelector works with and without a reference to it. Was this old behavior somehow unintended? Kind regards, Matthias -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] problem with RectangleSelector
On Tuesday, June 22, 2010 10:03:06 am Eric Firing wrote: On 06/21/2010 09:28 PM, Matthias Michler wrote: On Monday, June 21, 2010 06:30:04 pm Eric Firing wrote: On 06/21/2010 06:10 AM, Matthias Michler wrote: Hello list, I'm encountering a strange problem with the RectangleSelector using the latest version of svn. Namely it doesn't work if it wasn't initialized as RS = RectangleSelector(...) but using RectangleSelector(...) in my script. I modified the example rectangle_selector.py from the folder examples/widgets to illustrate my observation. Can anybody reproduce my findings or even explain what is going on? If you don't keep a reference to the RectangleSelector object, it vanishes--it is garbage-collected. Eric Hi Eric, thanks for your reply. That sounds reasonable, but I'm still confused. With the matplotlib release 0.99.1.1 the RectangleSelector works with and without a reference to it. Was this old behavior somehow unintended? Hi Eric, I don't know. In both cases, are you trying it in a script, and running it outside ipython? Ipython keeps references to inputs and outputs. yes I'm just using python rectangle_selector.py with the slightly modified script I have sent last time for matplotlib-svn and additionally comment out the 'button' - keyword argument for the release 0.99.1.1. The only difference between the two runs is whether matplotlib-svn is found in the PYTHONPATH or not. There haven't been many changes to widgets.py, and I don't see anything that could account for the difference I also don't see what could keep it alive if you don't keep a reference to it. If the same externally-run script works differently in this respect between the two mpl versions, then I'm baffled. I'm baffled, too. That was what made starting this thread and hope for an explanation, what I'm doing wrong. Kind regards, Matthias -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] displaying multiple images in series
Hi Daniel, show should be called only once in a script (see also: http://matplotlib.sourceforge.net/faq/howto_faq.html?highlight=show#use-show) and it starts the mainloop, in which the user may interact with the plot using for instance button or key press events like in my second example. Whenever a key-press-event is recognized the function event_fct is called with the corresponding key-press-event as argument. This key-press-event holds information like which key was used etc.. All the possible interaction you can have with the plot in this case happens after the plt.show in the mainloop, where matplotlib waits for events to happen and calls the corresponding functions, which were connected to the event. You will find more information about the event handling in the documentation of matplotlib (e.g. http://matplotlib.sourceforge.net/users/event_handling.html#event-handling- tutorial or the examples at http://matplotlib.sourceforge.net/examples/event_handling/index.html). In my first example the trick is done by the function waitforbuttonpress and all the interaction happens before the show-command. Because I'm not so familiar with this function, I suggest you again to use the documentation and the examples to learn more about this functionality. Kind regards, Matthias On Monday, June 21, 2010 05:47:21 am you wrote: Hi Matthias, Thanks for the script! Now I would like to try to understand why it works :) . In both of the scripts you sent me, plt.draw() is called inside the loop to display each image file, and plt.show() is called outside the loop at the end of the script. I guess what I find confusing is, how is it that the images are displayed on screen, inside the loop, *before* plt.show() is called? I would have expected only the very last image inside the loop to be displayed, using this program structure. So apparently there is something here I do not understand... -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] problem with RectangleSelector
Hello list, I'm encountering a strange problem with the RectangleSelector using the latest version of svn. Namely it doesn't work if it wasn't initialized as RS = RectangleSelector(...) but using RectangleSelector(...) in my script. I modified the example rectangle_selector.py from the folder examples/widgets to illustrate my observation. Can anybody reproduce my findings or even explain what is going on? Thanks in advance for any comments. Kind regards, Matthias Do a mouseclick somewhere, move the mouse to some destination, release the button. This class gives click- and release-events and also draws a line or a box from the click-point to the actual mouseposition (within the same axes) until the button is released. Within the method 'self.ignore()' it is checked wether the button from eventpress and eventrelease are the same. from matplotlib.widgets import RectangleSelector import numpy as np import matplotlib.pyplot as plt def line_select_callback(eclick, erelease): 'eclick and erelease are the press and release events' x1, y1 = eclick.xdata, eclick.ydata x2, y2 = erelease.xdata, erelease.ydata print (%3.2f, %3.2f) -- (%3.2f, %3.2f) % (x1, y1, x2, y2) print The button you used were: , eclick.button, erelease.button def toggle_selector(event): print ' Key pressed.' if event.key in ['Q', 'q'] and toggle_selector.RS.active: print ' RectangleSelector deactivated.' toggle_selector.RS.set_active(False) if event.key in ['A', 'a'] and not toggle_selector.RS.active: print ' RectangleSelector activated.' toggle_selector.RS.set_active(True) current_ax = plt.subplot(111)# make a new plotingrange N = 10 # If N is large one can see x = np.linspace(0.0, 10.0, N)# improvement by use blitting! plt.plot(x, +np.sin(.2*np.pi*x), lw=3.5, c='b', alpha=.7) # plot something plt.plot(x, +np.cos(.2*np.pi*x), lw=3.5, c='r', alpha=.5) plt.plot(x, -np.sin(.2*np.pi*x), lw=3.5, c='g', alpha=.3) print \n click -- release # drawtype is 'box' or 'line' or 'none' #toggle_selector.RS = #RS = RectangleSelector(current_ax, line_select_callback, drawtype='box', useblit=True, button=[1,3], # don't use middle button minspanx=5, minspany=5, spancoords='pixels') #plt.connect('key_press_event', toggle_selector) plt.show() -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] displaying multiple images in series
On Monday, June 14, 2010 10:32:48 pm Daniel Jones wrote: Hi matplotlib users, I'm trying to write a script to loop through a bunch of tiff files, display each image, and choose to accept or reject each image. Something like: for f in files: im = imread(f) imshow(im) # Accept keyboard input to accept or reject image # Close the image The problem is that I can't figure out how to show multiple images in series. I can't use matplotlib.pyplot.show() because that can only be used once at the very end of a script, and I don't want to show all the images at once. matplotlib.pyplot.draw() seemed like a promising candidate, but it only seems to work if I've already used show() once in the script. It seems like there should be a simple way to do this, but I can't quite seem to find it. Thanks, Daniel Hi Daniel, in the attached script I propose two solutions for your problem (just uncomment first region and comment second to test the first proposal). The first uses plt.waitforbuttonpress and the second key-press-events. Kind regards, Matthias import numpy as np import matplotlib.pyplot as plt file_list = ['a', 'b', 'c', 'd'] ax = plt.subplot(111) ### vvv --- first attempt using 'plt.waitforbuttonpress' --- ##plt.hold(False) ##for index, file in enumerate(file_list): ### im = plt.imread(file) ##im = np.random.uniform(size=(30, 20)) # some random data ##ax.imshow(im) ##ax.set_title(use (key-press) or reject (button press) image %i % (index)) ##plt.draw() ##result = plt.waitforbuttonpress() ##print result :, result ##plt.show() ### ^^^ --- first attempt using 'plt.waitforbuttonpress' --- # vvv --- second attempt using 'plt.connect and key press events' def event_fct(event): evaluate key-press events global counter if event is None: counter = 0 else: if event.key in ['r', 'u']: if event.key in 'r': print reject image elif event.key in 'u': print use image # go to next image counter += 1 else: print Key %s is not defined % (event.key) return # im = plt.imread(file_list[counter]) im = np.random.uniform(size=(30, 20)) # some random data ax.imshow(im) ax.set_title([u]se or [r]eject image %i by key press % (counter)) plt.draw() event_fct(None) # initial setup plt.connect('key_press_event', event_fct) plt.show() # ^^^ --- second attempt using 'plt.connect and key press events' -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] patch: adding kwargs 'which' in axes.grid and 'g' toggles all tick grid lines
On Wednesday, June 09, 2010 08:00:13 pm Eric Firing wrote: On 06/08/2010 11:07 PM, Matthias Michler wrote: On Wednesday, June 09, 2010 11:00:31 am Eric Firing wrote: On 06/08/2010 10:48 PM, Matthias Michler wrote: On Friday, April 23, 2010 11:08:50 am Matthias Michler wrote: Hello list, Hello developers, I'd like to summarize my discussion with Gökhan (Turning off minor grids on log scaled plot) in the last days and propose two patches. The first patch adds the keyword argument 'which' from the axis.grid to the method 'grid' of the Axes (axes_grid_for_major_and_minor_ticks.patch). This allows to change the drawing of grid lines for x- and y-axis at the same time. Furthemore Gökhan proposed to toggle *all* (namely major and minor tick) grid lines after pressing the key 'g'. Therefore the call event.inaxes.grid(), which toggles only the (default) major tick grid lines, is replaced by event.inaxes.grid(which='majorminor') (see toggling_all_tick_grid_lines.patch). This yields the expected behavior if e.g. all (major and minor) tick grid lines are shown, because than toggling the grid means to remove all grid lines. But to be honest I'm not sure the latter is the intended behavior in all cases. For instance in the case of shown major tick lines toggling all means turning off major tick lines and turning on minor tick lines by pressing 'g'. This sounds a little bit crazy to me, although that's what toggling is about. I think that behavior would indeed drive the user crazy, so I would not want to commit a patch that does that. Eric Hi Eric, thanks a lot for your comment. What do you think about the first part namely adding the kwarg 'which' from the axis method to the Axes method grid? I went ahead and did it in 8402--check to see that this is what you had in mind. The which kwarg can be 'both', 'minor', or 'major'. Hi Eric, thanks a lot for this commit. This is exactly what I wanted. There is only one thing about the new possibilities 'both', 'minor', or 'major'. The first possibility replaces 'majorminor', 'minormajor', 'some_string_including_major_and_minor', ... and I'm afraid that this could break someone's code. Kind regards, Matthias -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] patch: adding kwargs 'which' in axes.grid and 'g' toggles all tick grid lines
On Thursday, June 10, 2010 09:57:44 am Eric Firing wrote: On 06/09/2010 09:15 PM, Matthias Michler wrote: On Wednesday, June 09, 2010 08:00:13 pm Eric Firing wrote: On 06/08/2010 11:07 PM, Matthias Michler wrote: On Wednesday, June 09, 2010 11:00:31 am Eric Firing wrote: On 06/08/2010 10:48 PM, Matthias Michler wrote: On Friday, April 23, 2010 11:08:50 am Matthias Michler wrote: Hello list, Hello developers, I'd like to summarize my discussion with Gökhan (Turning off minor grids on log scaled plot) in the last days and propose two patches. The first patch adds the keyword argument 'which' from the axis.grid to the method 'grid' of the Axes (axes_grid_for_major_and_minor_ticks.patch). This allows to change the drawing of grid lines for x- and y-axis at the same time. Furthemore Gökhan proposed to toggle *all* (namely major and minor tick) grid lines after pressing the key 'g'. Therefore the call event.inaxes.grid(), which toggles only the (default) major tick grid lines, is replaced by event.inaxes.grid(which='majorminor') (see toggling_all_tick_grid_lines.patch). This yields the expected behavior if e.g. all (major and minor) tick grid lines are shown, because than toggling the grid means to remove all grid lines. But to be honest I'm not sure the latter is the intended behavior in all cases. For instance in the case of shown major tick lines toggling all means turning off major tick lines and turning on minor tick lines by pressing 'g'. This sounds a little bit crazy to me, although that's what toggling is about. I think that behavior would indeed drive the user crazy, so I would not want to commit a patch that does that. Eric Hi Eric, thanks a lot for your comment. What do you think about the first part namely adding the kwarg 'which' from the axis method to the Axes method grid? I went ahead and did it in 8402--check to see that this is what you had in mind. The which kwarg can be 'both', 'minor', or 'major'. Hi Eric, thanks a lot for this commit. This is exactly what I wanted. There is only one thing about the new possibilities 'both', 'minor', or 'major'. The first possibility replaces 'majorminor', 'minormajor', 'some_string_including_major_and_minor', ... and I'm afraid that this could break someone's code. The docstring for Axis.grid used to say Set the axis grid on or off; b is a boolean. Use *which* = 'major' | 'minor' to set the grid for major or minor ticks. This is pretty clear--*which* is 'major' or 'minor', not a string that might contain either or both. How would a user have gotten the idea that the API included 'majorminor'? Was it documented somewhere else? Granted, because it was written using a string search to parse the kwarg, any string containing major and or minor would work, but this strikes me as a bad API, and not in keeping with the rest of mpl. Given the docstring, I suspect that the behavior was actually accidental. Both the code and the docstring have been the same since at least 2004--I got tired of tracing it back in time. In this case I am inclined to make the behavior consistent with the docstring, and then enhance it with the both option, as I did. Was there a mailing list thread pointing out that majorminor etc would actually work, contrary to the docstring? Hi Eric, you are right that there is no documentation about this and maybe I'm the only guy how thought that this functionality is included. There were actually 2 threads, on which I proposed this as part of a solution: [Matplotlib-users] problem with minorticks from end of march 2010 and the thread [Matplotlib- users] Turning off minor grids on log scaled plot of april 2010, where the latter gave the starting point for the later proposed patch. I'm sorry for causing this confusion and wasting your time. Nontheless thank you for fully including the possibility to change both major and minor ticks at the same time. Kind regards, Matthias -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] patch: adding kwargs 'which' in axes.grid and 'g' toggles all tick grid lines
On Friday, April 23, 2010 11:08:50 am Matthias Michler wrote: Hello list, Hello developers, I'd like to summarize my discussion with Gökhan (Turning off minor grids on log scaled plot) in the last days and propose two patches. The first patch adds the keyword argument 'which' from the axis.grid to the method 'grid' of the Axes (axes_grid_for_major_and_minor_ticks.patch). This allows to change the drawing of grid lines for x- and y-axis at the same time. Furthemore Gökhan proposed to toggle *all* (namely major and minor tick) grid lines after pressing the key 'g'. Therefore the call event.inaxes.grid(), which toggles only the (default) major tick grid lines, is replaced by event.inaxes.grid(which='majorminor') (see toggling_all_tick_grid_lines.patch). This yields the expected behavior if e.g. all (major and minor) tick grid lines are shown, because than toggling the grid means to remove all grid lines. But to be honest I'm not sure the latter is the intended behavior in all cases. For instance in the case of shown major tick lines toggling all means turning off major tick lines and turning on minor tick lines by pressing 'g'. This sounds a little bit crazy to me, although that's what toggling is about. Thanks in advance for any comments. Kind regards, Matthias Hello list, Does anybody think the proposed patches could be useful? If somebody would benefit from them I'd be happy to place an updated version of the patch(es) at the patch tracker. Thanks in advance for any comments. Kind regards, Matthias -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] patch: adding kwargs 'which' in axes.grid and 'g' toggles all tick grid lines
On Wednesday, June 09, 2010 11:00:31 am Eric Firing wrote: On 06/08/2010 10:48 PM, Matthias Michler wrote: On Friday, April 23, 2010 11:08:50 am Matthias Michler wrote: Hello list, Hello developers, I'd like to summarize my discussion with Gökhan (Turning off minor grids on log scaled plot) in the last days and propose two patches. The first patch adds the keyword argument 'which' from the axis.grid to the method 'grid' of the Axes (axes_grid_for_major_and_minor_ticks.patch). This allows to change the drawing of grid lines for x- and y-axis at the same time. Furthemore Gökhan proposed to toggle *all* (namely major and minor tick) grid lines after pressing the key 'g'. Therefore the call event.inaxes.grid(), which toggles only the (default) major tick grid lines, is replaced by event.inaxes.grid(which='majorminor') (see toggling_all_tick_grid_lines.patch). This yields the expected behavior if e.g. all (major and minor) tick grid lines are shown, because than toggling the grid means to remove all grid lines. But to be honest I'm not sure the latter is the intended behavior in all cases. For instance in the case of shown major tick lines toggling all means turning off major tick lines and turning on minor tick lines by pressing 'g'. This sounds a little bit crazy to me, although that's what toggling is about. I think that behavior would indeed drive the user crazy, so I would not want to commit a patch that does that. Eric Hi Eric, thanks a lot for your comment. What do you think about the first part namely adding the kwarg 'which' from the axis method to the Axes method grid? Kind regards, Matthias -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] problem with annotate
Hello list, I'm encountering a problem with annotate using the latest svn and GTKAgg- backend. I plot several annotate-arrows in my script, but some of them aren't saved to the eps/pdf - file. More precisely the lower left arrow in the attached example, who touches the lower (negative) boundary of the plot arrea shows up in the matplotlib figure and the png-picture, but not in the pdf / eps output. It seems to be important that in my case the lower limit of the y-axis is negative. I found two solutions to this problems, which are the middle and right of the lower arrows, but I don't understand why this is needed. The middle arrow does not touch the lower boundary and the right arrow has an inverted direction and inverted arrowstyle. Is this a bug or did I miss something? Kind regards and thanks in advance for any hints. Matthias attachment: annotate_error.eps annotate_error.pdf Description: Adobe PDF document attachment: annotate_error.pngimport matplotlib.pyplot as plt ax = plt.subplot(111) plt.axis([0.0, 0.4, -0.5, 0.5]) ax.annotate(, xy = (0.1, 0.2), xytext = (0.1, 0.5), arrowprops = dict(arrowstyle = -)) ax.annotate(, xy = (0.2, 0.5), xytext = (0.2, 0.2), arrowprops = dict(arrowstyle = -)) ax.annotate(, xy = (0.3, 0.2), xytext = (0.3, 0.5), arrowprops = dict(arrowstyle = -)) ax.annotate(, xy = (0.1, -0.5), xytext = (0.1, -0.2), arrowprops = dict(arrowstyle = -)) ax.annotate(, xy = (0.2, -0.4), xytext = (0.2, -0.2), arrowprops = dict(arrowstyle = -)) ax.annotate(, xy = (0.3, -0.2), xytext = (0.3, -0.5), arrowprops = dict(arrowstyle = -)) plt.savefig(annotate_error.eps) plt.savefig(annotate_error.pdf) plt.savefig(annotate_error.png) plt.show() -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] semilogy with dates on x?
On Thursday, May 13, 2010 12:31:08 am Alan G Isaac wrote: What is the preferred method to do the equivalent of plot_date with log scaling for the non-date values? Thanks, Alan Isaac Hi Alan, What about using 'plot_date' ans scaling the y-axis by hand? In the example 'date_demo1.py' you would have to change -ax = fig.add_subplot(111) to: +ax = fig.add_subplot(111, yscale='log') or for any other generated axes 'ax' ax.set_yscale('log') Does this help you? Kind regards, Matthias -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plotting a vector in matplotlib
On Sunday 02 May 2010 20:19:29 aditya bhargava wrote: Is there a straightforward way of plotting a vector in matplotlib? Suppose I want to plot the vector [1 2]'. If I pass this vector in to plot(), I get the line that passes through (0,1), (1,2). Instead I want the line that passes through (0,0),(1,2). Aditya Hi Aditya, if you pass a 1-dimensional interatable to the plot-function the elements are plotted over their indices. In your case [1, 2] gives the y-values and the indices [0, 1] are used as x-values. I don't know if there is some kind of vector class yet, but meanwhile you could set up your one like in the attached small example. Kind regards, Matthias simple_vector_class.py Description: application/python -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Horizontal and vertical lines between subplots
On Wednesday 28 April 2010 15:07:21 Maxime Bois wrote: Hi all, I have created a figure with 4 subplots (2x2) and I want to separate them with a vertical and horizontal lines (see the green lines on my figure edited by Gimp) but I don't know if it's possible (I haven't find any example of that). I am using Python 2.5.4 and matplotlib version 0.99.0 Thanks, Maxime Hi Maxime, I hope my example works for you. Please note: I used plt.axes instead of plt.subplot, although both generate an Axes instance, the latter doesn't support overlapping axes. Kind regards, Matthias 2by2_subplot_separated_by_lines.py Description: application/python -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotyy equivalent example -- png output
On Thursday 29 April 2010 15:02:34 James Jack wrote: Below is the working code to plot two different data series with different units on the same graph, with the same x co-ordinates: import pylab # generate some data x = range(0, 10) y1 = [i*i for i in x] y2 = [pylab.sin(0.4*i) for i in x] # the data share x axis but have different y units figure = pylab.gcf() # Get the current figure orig_axis = pylab.gca()# Get the current axis orig_axis.set_axis_off() # Turn it off to avoid complications # use this for the overlapping axes box = [0.14, 0.14, 0.72, 0.72] # This uses the first set of data axis1 = figure.add_axes(box, label = 'axis1') axis1.set_title('TITLE') axis1.plot(x, y1, '-^y') axis1.set_ylabel('AXIS 1 LABEL') axis1.set_xlabel('SHARED X LABEL') axis1.spines['right'].set_visible(False) # This uses the second set of data # Note the same box region is used but the label must be different axis2 = figure.add_axes(box, label = 'axis2') axis2.plot(x, y2, '-sb') axis2.yaxis.set_ticks_position('right') axis2.yaxis.set_label_position('right') axis2.set_ylabel('AXIS 2 LABEL') axis2.spines['bottom'].set_visible(False) axis2.spines['top'].set_visible(False) axis2.spines['left'].set_visible(False) # Write out to a file pylab.savefig('out.png', dpi = 100, transparent = True) Issues: 1) I can't use show() in this case because there is no Transparent parameter. 2) It's still a botch. 3) I tried using alpha but it didn't seem to work at all? Does anyone have a better implementation of this or better ideas? Many thanks James Hi James, I'm not sure I completely understand your problem, but for me it seems like the twinx-method of an Axes instance is what you need (see for instance: http://matplotlib.sourceforge.net/examples/api/two_scales.html) for your example something like the following should work import pylab # generate some data x = range(0, 10) y1 = [i*i for i in x] y2 = [pylab.sin(0.4*i) for i in x] # the data share x axis but have different y units figure = pylab.gcf() # Get the current figure box = [0.14, 0.14, 0.72, 0.72] ax1 = figure.add_axes(box) ax1.set_ylabel('axis1', color='b') ax2 = ax1.twinx() ax2.set_ylabel('axis2', color='g', ) ax1.plot(x, y1, '-^y', color='blue') ax2.plot(x, y2, '-^y', color='green') # Make the y-tick labels of first axes match the line color. for tl in ax1.get_yticklabels(): tl.set_color('b') pylab.show() Kind regards, Matthias -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bug in ContourSet and additional kwargs
On Wednesday 28 April 2010 09:21:54 Eric Firing wrote: Matthias Michler wrote: [...] First of all I think my previously described error in the over-color is due to a bug in the set up of the colors.ListedColormap during the initialisation of ContourSet if 'self.colors' is not None. For the number of entries in the map 'N' the number of layers is passed N=len(self.layers), which is not useful if self.extend is 'both'. Let's say I want 3 regions and provide 3 colors. If extend is 'both' the number of layers is the #{colored regions between min and max} + 2 = 5. For N=5 in the initialisation of the ListedColormap the list of colors is extended to have length 'N=5' (by repetition). Therefore an additional layer (more precisely 2) occurs in the colormap and although the over_color is set to something different the (repeted) first element of 'colors' is used to color values above the highest level. I propose the following case differentiation: if self.extend == both: N = len(self.layers) - 2 elif self.extend in ('max', 'min'): N = len(self.layers) - 1 else: N = len(self.layers) Maybe N = len(self.levels) - 1 is always a good solution. Is this a bug and does my proposal resolve it without destroying something else? Matthias, I think I have fixed the problem. I also changed the second plot in contourf_demo to include the extended colorbar. Attached is a modification of one of your illustrative scripts with some unnecessary kwargs stripped out. In particular, when contourf makes a ListedColormap, you don't need or want to specify the norm--it uses the appropriate one, which is NoNorm. Also, you probably don't need to specify the view limits when making the subplot (contourf will autoscale with tight boundaries), and you don't need to pass the extend kwarg to colormap--it gets it from the ContourSet object. Eric Hi Eric, thanks a lot for fixing this bug and including an extended colorbar in the examples. Kind regards, Matthias -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] patch: adding kwargs 'which ' in axes.grid and 'g' toggles all tick g rid lines
[bringing it back to list] On Monday 26 April 2010 18:08:15 Pribadi, Krishna wrote: Hi Matt, Nice patch. Sorry this is a newbie question... How do you run this patch? Hi Krishna, this patch is a diff against matplotlib-svn-trunk and you need a working copy of this to incorporate the patch automatically (instead of changing the lines by hand). The patch was generated using svn diff filenamename.patch You can apply this patch to your working copy of matplotlibs svn by calling patch -i name.patch -p0 here e.g.: patch -i axes_grid_for_major_and_minor_ticks.patch -p0 in the folder of your working copy or allpying it to a single file here e.g.: patch lib/matplotlib/axes.py axes_grid_for_major_and_minor_ticks.patch Kind regards, Matthias Krishna Adrianto Pribadi Test Engineer Desk (TTF): 256.480.4450 Cell: 412.401.1477 Harley-Davidson Motor Co. Talladega Test Facility Vehicle Test Stands (VTS) -Original Message- From: Matthias Michler [mailto:matthiasmich...@gmx.net] Sent: Friday, April 23, 2010 4:09 AM To: matplotlib-users@lists.sourceforge.net Subject: [Matplotlib-users] patch: adding kwargs 'which' in axes.grid and 'g' toggles all tick grid lines Hello list, Hello developers, I'd like to summarize my discussion with Gökhan (Turning off minor grids on log scaled plot) in the last days and propose two patches. The first patch adds the keyword argument 'which' from the axis.grid to the method 'grid' of the Axes (axes_grid_for_major_and_minor_ticks.patch). This allows to change the drawing of grid lines for x- and y-axis at the same time. Furthemore Gökhan proposed to toggle *all* (namely major and minor tick) grid lines after pressing the key 'g'. Therefore the call event.inaxes.grid(), which toggles only the (default) major tick grid lines, is replaced by event.inaxes.grid(which='majorminor') (see toggling_all_tick_grid_lines.patch). This yields the expected behavior if e.g. all (major and minor) tick grid lines are shown, because than toggling the grid means to remove all grid lines. But to be honest I'm not sure the latter is the intended behavior in all cases. For instance in the case of shown major tick lines toggling all means turning off major tick lines and turning on minor tick lines by pressing 'g'. This sounds a little bit crazy to me, although that's what toggling is about. Thanks in advance for any comments. Kind regards, Matthias -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Setting color of both major and minor gridlines?
On Monday 26 April 2010 18:59:41 KrishnaPribadi wrote: Peter Buschman-2 wrote: I ended up finding a solution to this by using a FixedLocator and manually setting each of the tick positions for both major and minor grids without overlap. I'm not sure if this is the recommended way to do this, but hey, it worked ;-) for tick in range(seconds+1)[1:]: if tick % major_multiple == 0: xmajorticks.append(tick) elif tick % minor_multiple == 0: xminorticks.append(tick) ax.xaxis.set_major_locator(FixedLocator(xmajorticks)) ax.xaxis.set_minor_locator(FixedLocator(xminorticks)) Hi there, I know this is an old post, but I'm also trying to do something similar, but using different linestyles for the major and minor grids. Has anyone figured out code that's more efficient than this? It seems that this can slow down my application's data load time. Also, since I'm using the zoom widget, I'm not certain if this will work if the tick markers change If I change my x limits... Any thoughts? Hi Krishna, I'm not sure about using FixedLocator if you want to zoom ... What about the following approach: from matplotlib import pyplot as plt ax = plt.subplot(111, autoscale_on=False, xlim=(10, 1000), ylim=(10, 1000)) ax.set_xscale('log') ax.set_yscale('log') ax.grid(which='major', linestyle='-', color='blue') ax.grid(which='minor', linestyle='--', color='red') plt.show() Kind regards, Matthias -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] bug in ContourSet and additional kwargs
Hello list, Hi Eric, I stumbled upon the old thread ploting matrix data and the changes in my mpl-svn working copy allowing to provide under_color and over_color as a keyword argument of contourf. On Tuesday 14 April 2009 20:39:06 Eric Firing wrote: Matthias Michler wrote: [snip] Second question: Could it be useful to add two kwargs 'over_color' and 'under_color' to contourf in order to allow specification of a extended ListedColormap by kwarg 'colors' and these two colors? I tried to include this in the attached patch (added_under_and_over_color_to_ContourSet.patch) and use it in the example contourf_with_extended_colorbar_new.py. But it dosn't work completely correct. Although the over color is correctly set to cyan in the cmap In [14]: my_contourf.cmap._rgba_over Out[14]: (0.0, 1.0, 1.0, 1.0) red is used for values above the colormap-bounds. Thanks in advance for any comments and hints. I need to look at your patch--but a priori, I am a bit worried about the tendency of APIs to get more and more complicated, with more and more kwargs, as time goes on. Eric First of all I think my previously described error in the over-color is due to a bug in the set up of the colors.ListedColormap during the initialisation of ContourSet if 'self.colors' is not None. For the number of entries in the map 'N' the number of layers is passed N=len(self.layers), which is not useful if self.extend is 'both'. Let's say I want 3 regions and provide 3 colors. If extend is 'both' the number of layers is the #{colored regions between min and max} + 2 = 5. For N=5 in the initialisation of the ListedColormap the list of colors is extended to have length 'N=5' (by repetition). Therefore an additional layer (more precisely 2) occurs in the colormap and although the over_color is set to something different the (repeted) first element of 'colors' is used to color values above the highest level. I propose the following case differentiation: if self.extend == both: N = len(self.layers) - 2 elif self.extend in ('max', 'min'): N = len(self.layers) - 1 else: N = len(self.layers) Maybe N = len(self.levels) - 1 is always a good solution. Is this a bug and does my proposal resolve it without destroying something else? Now back to my previous proposal to include the additional keyword arguments 'under_color' and 'over_color'. I attached two scripts, which show the difference between the old and the new usage of a listed colormap specifing under/over_color. In the old behavior you have to set the under and over color after setting up the contour. my_contourf.cmap.set_over('cyan') my_contourf.cmap.set_under('yellow') and in the new behavior you can pass over_color='cyan', under_color='yellow', to the contourf-function. Could these keyword arguments be useful? Thanks in advance for any comments. Kind regards, Matthias contourf_with_extended_colorbar_NEW.py Description: application/python contourf_with_extended_colorbar_OLD.py Description: application/python -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] patch: adding kwargs 'which' in axes.grid and 'g' toggles all tick grid lines
Hello list, Hello developers, I'd like to summarize my discussion with Gökhan (Turning off minor grids on log scaled plot) in the last days and propose two patches. The first patch adds the keyword argument 'which' from the axis.grid to the method 'grid' of the Axes (axes_grid_for_major_and_minor_ticks.patch). This allows to change the drawing of grid lines for x- and y-axis at the same time. Furthemore Gökhan proposed to toggle *all* (namely major and minor tick) grid lines after pressing the key 'g'. Therefore the call event.inaxes.grid(), which toggles only the (default) major tick grid lines, is replaced by event.inaxes.grid(which='majorminor') (see toggling_all_tick_grid_lines.patch). This yields the expected behavior if e.g. all (major and minor) tick grid lines are shown, because than toggling the grid means to remove all grid lines. But to be honest I'm not sure the latter is the intended behavior in all cases. For instance in the case of shown major tick lines toggling all means turning off major tick lines and turning on minor tick lines by pressing 'g'. This sounds a little bit crazy to me, although that's what toggling is about. Thanks in advance for any comments. Kind regards, Matthias Index: lib/matplotlib/axes.py === --- lib/matplotlib/axes.py (revision 8267) +++ lib/matplotlib/axes.py (working copy) @@ -1932,19 +1932,20 @@ self._axisbelow = b @docstring.dedent_interpd -def grid(self, b=None, **kwargs): +def grid(self, b=None, which='major', **kwargs): call signature:: - grid(self, b=None, **kwargs) + grid(self, b=None, which='major', **kwargs) -Set the axes grids on or off; *b* is a boolean +Set the axes grids on or off; *b* is a boolean. Use *which* = +'major' | 'minor' to set the grid for major or minor ticks. If *b* is *None* and ``len(kwargs)==0``, toggle the grid state. If *kwargs* are supplied, it is assumed that you want a grid and *b* is thus set to *True* -*kawrgs* are used to set the grid line properties, eg:: +*kwargs* are used to set the grid line properties, eg:: ax.grid(color='r', linestyle='-', linewidth=2) @@ -1953,8 +1954,8 @@ %(Line2D)s if len(kwargs): b = True -self.xaxis.grid(b, **kwargs) -self.yaxis.grid(b, **kwargs) +self.xaxis.grid(b, which=which, **kwargs) +self.yaxis.grid(b, which=which, **kwargs) def ticklabel_format(self, **kwargs): Index: lib/matplotlib/backend_bases.py === --- lib/matplotlib/backend_bases.py (revision 8267) +++ lib/matplotlib/backend_bases.py (working copy) @@ -2109,9 +2109,9 @@ # the mouse has to be over an axes to trigger these # switching on/off a grid in current axes (default key 'g') if event.key in grid_keys: -event.inaxes.grid() +event.inaxes.grid(which=majorminor) self.canvas.draw() -# toggle scaling of y-axes between 'log and 'linear' (default key 'l') +# toggle scaling of y-axes between 'log' and 'linear' (default key 'l') elif event.key in toggle_yscale_keys: ax = event.inaxes scale = ax.get_yscale() @@ -2121,7 +2121,7 @@ elif scale == 'linear': ax.set_yscale('log') ax.figure.canvas.draw() -# toggle scaling of x-axes between 'log and 'linear' (default key 'k') +# toggle scaling of x-axes between 'log' and 'linear' (default key 'k') elif event.key in toggle_xscale_keys: ax = event.inaxes scalex = ax.get_xscale() -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Turning off minor grids on log scaled plot
On Wednesday 21 April 2010 19:06:09 Gökhan Sever wrote: On Wed, Apr 21, 2010 at 4:39 AM, Matthias Michler matthiasmich...@gmx.netwrote: I think it works like expected, i.e. it toggles the state of showing grid lines for minor and major ticks. The problem it the case were people set only major tick grid lines ax.grid(True, which='major') and than press the key 'g', because than they change between having major and minor tick grid lines and this is somehow a strange behavior, isn't it? Therefore I myself am not convinced of that solution. [...] Interesting that setting and using g doesn't toggle both minor and major grids at the same time. It behaves erratically. event.inaxes.grid(which='minormajor') Hi Gökhan, Just to make one point clear to me. Do you agree that the following is the expected behavior of your suggestion to use event.inaxes.grid(which='minormajor') after 'g'? If only the major tick grid lines are shown and the user presses 'g' the major tick lines are removed and the minor tick lines are shown, because calling Axes.grid with the default b=None toggles the state of plotting grid lines. Here this means that the minor tick grid lines are switched from being not shown to being shown and the major tick lines change vice versa. If you agree that this is the expected behavior of your suggestion, do you think this is a useful behavior? Kind regards, Matthias -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Turning off minor grids on log scaled plot
On Wednesday 21 April 2010 08:10:00 Gökhan Sever wrote: On Tue, Apr 20, 2010 at 11:11 AM, Gökhan Sever gokhanse...@gmail.comwrote: On Tue, Apr 20, 2010 at 2:42 AM, Matthias Michler matthiasmich...@gmx.net wrote: Hi Gökhan, thanks for testing this small patch. Maybe one of the developers could submit it or should I place it on the patch-tracker? Usually after some pinging someone picks up the code and commits in to the svn. About the toggling of all grid-lines using event.inaxes.grid(which='majorminor') I not sure this is intended, because this means that you will allways toggling major and minor tick - grid lines using key 'g' instead of only toggling major tick grid lines. Maybe a developer or other users could comment on the preferred behavior. Just create a simple plot and log-log x,y-axes and try hitting g. Both minor and major gridlines must be visible to get a clear view. In some cases grids clutter the figure instead of helping. In my previous post, the main point was change in event.inaxes.grid(which='majorminor') doesn't really work as expected. Could you at least check that behavior? I think it works like expected, i.e. it toggles the state of showing grid lines for minor and major ticks. The problem it the case were people set only major tick grid lines ax.grid(True, which='major') and than press the key 'g', because than they change between having major and minor tick grid lines and this is somehow a strange behavior, isn't it? Therefore I myself am not convinced of that solution. [...] I spotted another annoyance: Save the following lines in a file called test.py and run python test.py import matplotlib.pyplot as plt plt.plot(range(100)) plt.xscale('log') plt.yscale('log') ax = plt.gca() ax.grid(False, which='majorminor') plt.show() This doesn't work properly in the first call. If you call it from within Ipython -pylab using run test.py again no difference. Only when you call ax.grid(False, which='majorminor') grids disappear. I'm sorry, I don't get your point. If I ran your script I get a window without gridlines as expected. The result is independent of the call of ax.grid(False, which='majorminor'). By the way are you using matplotlib-svn? Kind regards, Matthias -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Turning off minor grids on log scaled plot
On Monday 19 April 2010 20:36:15 Gökhan Sever wrote: On Mon, Apr 19, 2010 at 1:31 AM, Matthias Michler matthiasmich...@gmx.netwrote: On Sunday 18 April 2010 00:52:57 Gökhan Sever wrote: Hello, Let say we have a figure created by: plt.plot(range(100)) On WX backend plt.grid(1) or key G responds finely for turning on/off the grid lines. However when I log-scale both axes then plt.grid(1 or 0) or G doesn't respond on minor grid lines. Is there a way to control this behavior? Thanks. Hi Gökhan, I can confirm your findings and I hope my attached patch (against current svn) solves this problem. In the axes.grid the boolean 'b' was set to 'True' if the kwarg 'which' was suplied, because it was part of the **kwargs and so always b was True in the axis (e.g. ax.xaxis). Now I get a grid on the minor-ticks by calling: ax.grid(True, which=majorminor) and remove the the minortick-grid lines / all grid lines by calling ax.grid(False, which=minor) ax.grid(False, which=majorminor) Kind regards, Matthias Works great both majorminor and minormajor works as a which keyword. One minor thing. When I updated backend_bases.py as it doesn't function correctly when I toggle G if event.key in grid_keys: event.inaxes.grid(which='majorminor') self.canvas.draw() Could you take a look this one as well? Thanks. This change should go into the svn. Hi Gökhan, thanks for testing this small patch. Maybe one of the developers could submit it or should I place it on the patch-tracker? About the toggling of all grid-lines using event.inaxes.grid(which='majorminor') I not sure this is intended, because this means that you will allways toggling major and minor tick - grid lines using key 'g' instead of only toggling major tick grid lines. Maybe a developer or other users could comment on the preferred behavior. Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] skipping mpl-axes-interaction during key_press_event's
On Wednesday 17 March 2010 15:58:11 Matthias Michler wrote: On Wednesday 17 March 2010 15:05:32 John Hunter wrote: On Wed, Mar 17, 2010 at 4:10 AM, Matthias Michler matthiasmich...@gmx.net wrote: once more I'd like to ask for comments about my feature request and proposed patch. Should I post it at the 'feature request' or 'patch' tracker? Thanks in advance for any comments. Hey Matthias -- This should be placed on the patch tracker, and you can respond back to this list with a link to the patch. I'll review it when I get a minute. Thanks for following up and for making patches against branch and HEAD. JDH Hi John, thanks for taking the time and the offer to review the patch. The new tracker is skipping mpl-axes-interaction during key_press_event\'s - ID: 2971996 (http://sourceforge.net/tracker/?func=detailaid=2971996group_id=80706atid=560722) Hi John, Hello list, this is the one month reminder of my patch, which allows to switch off key events that e.g. scale the y-axis via 'l' etc. . Please let me now, if there is anything I can do to improve the patch. Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Turning off minor grids on log scaled plot
On Sunday 18 April 2010 00:52:57 Gökhan Sever wrote: Hello, Let say we have a figure created by: plt.plot(range(100)) On WX backend plt.grid(1) or key G responds finely for turning on/off the grid lines. However when I log-scale both axes then plt.grid(1 or 0) or G doesn't respond on minor grid lines. Is there a way to control this behavior? Thanks. Hi Gökhan, I can confirm your findings and I hope my attached patch (against current svn) solves this problem. In the axes.grid the boolean 'b' was set to 'True' if the kwarg 'which' was suplied, because it was part of the **kwargs and so always b was True in the axis (e.g. ax.xaxis). Now I get a grid on the minor-ticks by calling: ax.grid(True, which=majorminor) and remove the the minortick-grid lines / all grid lines by calling ax.grid(False, which=minor) ax.grid(False, which=majorminor) Kind regards, Matthias Index: lib/matplotlib/axes.py === --- lib/matplotlib/axes.py (revision 8242) +++ lib/matplotlib/axes.py (working copy) @@ -1839,19 +1839,20 @@ self._axisbelow = b @docstring.dedent_interpd -def grid(self, b=None, **kwargs): +def grid(self, b=None, which='major', **kwargs): call signature:: grid(self, b=None, **kwargs) -Set the axes grids on or off; *b* is a boolean - +Set the axes grids on or off; *b* is a boolean. Use *which* = +'major' | 'minor' to set the grid for major or minor ticks. + If *b* is *None* and ``len(kwargs)==0``, toggle the grid state. If *kwargs* are supplied, it is assumed that you want a grid and *b* is thus set to *True* -*kawrgs* are used to set the grid line properties, eg:: +*kwargs* are used to set the grid line properties, eg:: ax.grid(color='r', linestyle='-', linewidth=2) @@ -1860,8 +1861,8 @@ %(Line2D)s if len(kwargs): b = True -self.xaxis.grid(b, **kwargs) -self.yaxis.grid(b, **kwargs) +self.xaxis.grid(b, which=which, **kwargs) +self.yaxis.grid(b, which=which, **kwargs) def ticklabel_format(self, **kwargs): -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] possible to specify RGB in set_under or set_over?
On Friday 16 April 2010 16:49:05 Dr. Phillip M. Feldman wrote: I would like to specify the colors to be used for plotting out-of-range values via RGB triples rather than color name strings. Is this possible? With matplotlib-svn it works for me. What version of mpl are you using? Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] color and transparency in overlapping regions
On Tuesday 13 April 2010 16:37:21 hettling wrote: Dear all, I want to plot 3 overlapping regions using fill() into one panel, but my solution looks sort of messy... Here is the code: [...snip...] The figure looks like 4 regions are plotted, because overlapping red and yellow make an orange region... I tried some different combination, but it never looked good. Does anybody have an idea how to chose the colors and 'alpha' values for transparency so that the plot looks good and could be printed? Any help is appreciated, thanks in advance, Hannes Hi Hannes, maybe hatching of the regions help to distinguish the 3 different regions of 4 regions (see the code below). Kind regards, Matthias === from matplotlib import pyplot as plt import numpy as np ##Data to plot seq = np.sin(range(0, 10)) xpts = np.concatenate((range(0, 10), range(0, 10)[::-1])) plt.figure() ##Plot 3 overlapping regions, a different color for each one for diff, color, hatch in zip([1, 2, 3], [blue, red, yellow], ['/', '|', '\\']): ypts = np.concatenate((seq - diff, (seq - diff * 2)[::-1])) plt.fill(xpts, ypts, alpha=0.7, fc=color, hatch=hatch, ec=black, lw=2, label=str(diff)) plt.legend() plt.show() === -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] skipping mpl-axes-interaction during key_press_event's
On Wednesday 17 March 2010 15:58:11 Matthias Michler wrote: On Wednesday 17 March 2010 15:05:32 John Hunter wrote: On Wed, Mar 17, 2010 at 4:10 AM, Matthias Michler matthiasmich...@gmx.net wrote: once more I'd like to ask for comments about my feature request and proposed patch. Should I post it at the 'feature request' or 'patch' tracker? Thanks in advance for any comments. Hey Matthias -- This should be placed on the patch tracker, and you can respond back to this list with a link to the patch. I'll review it when I get a minute. Thanks for following up and for making patches against branch and HEAD. JDH Hi John, thanks for taking the time and the offer to review the patch. The new tracker is skipping mpl-axes-interaction during key_press_event\'s - ID: 2971996 (http://sourceforge.net/tracker/?func=detailaid=2971996group_id=80706atid=560722) Hi John, I'm sorry for the additional traffic, but may I remind you of my patch, which allows to switch off key events like scaling yscale via 'l' etc.? Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to remove white space
On Thursday 01 April 2010 09:41:06 yogesh karpate wrote: Dear All, I have one .png image of 940X780 and i am plotting waveforms on it. When I save this plot as .png , matp[lotlib gives image in 800X600 that too with white space. I dont want to keep the white space and i want the same resolution as original image.How should I go ahead? Thanks in advance!!! Regards Yogesh Hi Yogesh, Doesn't the following example fulfill your needs (already posted to How to save file in to image in desired resolution in matplotlib?)? fig = plt.figure(figsize=(9.4, 7.8)) ax = plt.axes([0.0, 0.0, 1.0, 1.0]) # leaves no white space around the axes ax.plot([1, 2, 4], lw=5) ax.set_xticks([]) # removes ticks ax.set_yticks([]) fig.savefig('test.png', dpi=100) Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Change axis's scale
On Thursday 01 April 2010 12:27:59 timothee cezard wrote: Hi all, I have several graph to create and the position on the x axis can vary quite a lot. Most of the time I'm quite happy with the default behavior but when my x values are very high matplotlib automatically change the ticks and set a scale on the axis (see screenshot) http://img6.imageshack.us/img6/6834/chab052195802198642shif.png I looking for a way to change the default behavior to get a scale in 10E** instead of some random scale. Is there a simple way of doing that? Thanks a lot for your help Tim Hi Tim, the random scale you are observing is the originalscale, where some useful offset has been substracted and is shown in the lower right. You can circumvent this behaviour by using your own Formatter like a ScalarFormatter withour offset: formatter = plt.ScalarFormatter(useOffset=False) Furthermore you can switch off the scientific formatting (extracting a common prefactor) using formatter.set_scientific(False) Applying this formatter to the current axes: plt.gca().xaxis.set_major_formatter(formatter) or a string-formatter like majorFormatter = plt.FormatStrFormatter('%.5e') or majorFormatter = plt.FormatStrFormatter('%g') Kind regards, Matthias PS: By the way, you should start a new thread for a new topic (sending a new mail to mpl-users) instead of responding to another message. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to save file in to image in desired resolution in matplotlib?
On Wednesday 31 March 2010 09:24:10 yogesh karpate wrote: Dear All, I am using one image of 235X130 and plotting the curve on it, now when i save it it goes in the resoltuion of 800X600, I want to keep the resolution intact.What can be done for that to keep the resolution same? I am using savefig('/home/jaguar/Softwares/Development/Python/bunty.png') Thanks in advance! Regards Yogesh Hi Yogesh, You can adjust the resolution by changing the figure size and the dpi in savefig. Keyword of figure: *figsize* width x height in inches; defaults to rc figure.figsize Keyword of savefig: *dpi*: [ None | scalar 0 ] The resolution in dots per inch. If *None* it will default to the value ``savefig.dpi`` in the matplotlibrc file. e.g. import matplotlib matplotlib.use('Agg') from matplotlib import pyplot as plt # aim: 235X130 fig = plt.figure(figsize=(23.5, 13.0)) ax = plt.axes([0.0, 0.0, 1.0, 1.0]) ax.plot([1, 2, 4], lw=5) ax.set_xticks([]) ax.set_yticks([]) fig.savefig('test.png', dpi=10) Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] problem with minorticks
On Monday 29 March 2010 19:53:00 yogesh karpate wrote: Dear All, I want to make minor ticks working in following program. Here only major ticks are dis[played in grpah though i have declared the minor ticks minorticks_on() doesnt work in my code. How to fix that.Please help me out.Thanks in advance ' Regards Yogesh from numpy import * from scipy import * from scipy import signal, misc import sys,time,os,gc import matplotlib import matplotlib.pyplot as plt from numpy.random import * from pylab import plot, show, ylim, yticks,xlim from pylab import * x=loadtxt('/home/jaguar/Desktop/45.txt') x=x[0:1399] y=arange(len(x)) plt.figure(2) plt.plot(y,x,'k-') #minorticks_on() grid(True)#, color=r, ls=-) gca().xaxis.grid(True, which=minor, color=r) #gca().yaxis.grid(True, which='minor') #grid(True, which=minor, color=r) show()#l Hi Yogesh, using plt.minorticks_on() and plt.grid(True, which=majorminor, color=r) works for me (with matplotlib-svn). If minorticks_on() doesn't work for you, you could set the location of the minor ticks on your own as in my attached code or the examples: http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo1.html http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo2.html Kind regards, Matthias minor_ticks.py Description: application/python -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Issues with imshow
On Monday 29 March 2010 01:51:30 Sunman wrote: Hello, I am trying to use the imshow() function for a 2-dimensional array. However, I am having issues with the following: When the array is perfectly square the image looks like this: http://old.nabble.com/file/p28063442/Plot2.png but when it is not it looks like this: http://old.nabble.com/file/p28063442/Plot.png Is there any way I can line up the image for a rectangular array so that its in the top left corner? Hi, I'm not really sure I get your point, but you can try to play with the placement of the used subplot ``axes(rect)`` where *rect* = [left, bottom, width, height] in normalized (0, 1) units. e.g. ax = plt.axes([0.1, 0.2, 0.8, 0.6]) and with the kwargs of imshow (extent: limits of the picture and aspect : [ None | 'auto' | 'equal' | scalar ] ) e.g. a = np.arange(35).reshape(7, 5) ax.imshow(a, interpolation='nearest', extent=(0.0, 1.0, 0.0, 1.0), aspect='auto', origin='lower') Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matshow / imshow with date-axis
On Monday 29 March 2010 13:56:51 Atomfried wrote: Hi, is it possible to perform a surface plot a NxM matrix with date-axes? Similar to plot_date for 1D-Plots. The dates are available as an N-sized (or M-sized) array of float values. At the moment, I am using imshow or matshow for the color plots, but the only way I found to manipulate the axes is the 'extent' keyword argument, which is not sufficient in this context. Any hints? Micha Hi Micha, Did you already set the date-xaxis by hand? - for axes 'ax' using e.g. ax.xaxis_date(tz=None) ax.yaxis_date(tz=None) I would hope that extent and this together yield your aim, but I'm not so familiar with date-axes. Kind regards, Mattthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] skipping mpl-axes-interaction during key_press_event's
On Thursday 04 March 2010 09:43:40 Matthias Michler wrote: On Wednesday 03 March 2010 19:10:10 Matthias Michler wrote: Hello list, I'd like to bring something back, which was discussed in sep-dec 2008 OSX 10.5 event.key bug, which was initially posted by James Schombert. Did I miss any development in this field? I tried to implement the latest proposal, which allows you to switch off the mpl-axes-interaction during key_press_event's for a specific axes using ax.set_auto_key_press(False) Therefore I changed the backend_bases.py and the axes.py (see attachement). If this is a suitable solution, one could switch off the mpl-axes-interaction during key_press_event's for all axes belonging to a button, slider, ... . I attached an updated version of my patch including the handling of key-events, which have no axes associated (patch against svn-HEAD and maintance branch). Hello list, once more I'd like to ask for comments about my feature request and proposed patch. Should I post it at the 'feature request' or 'patch' tracker? Thanks in advance for any comments. Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] skipping mpl-axes-interaction during key_press_event's
On Wednesday 17 March 2010 15:05:32 John Hunter wrote: On Wed, Mar 17, 2010 at 4:10 AM, Matthias Michler matthiasmich...@gmx.net wrote: once more I'd like to ask for comments about my feature request and proposed patch. Should I post it at the 'feature request' or 'patch' tracker? Thanks in advance for any comments. Hey Matthias -- This should be placed on the patch tracker, and you can respond back to this list with a link to the patch. I'll review it when I get a minute. Thanks for following up and for making patches against branch and HEAD. JDH Hi John, thanks for taking the time and the offer to review the patch. The new tracker is skipping mpl-axes-interaction during key_press_event\'s - ID: 2971996 (http://sourceforge.net/tracker/?func=detailaid=2971996group_id=80706atid=560722) Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how can I show some figures, but not others?
On Tuesday 16 March 2010 14:17:26 Nick Schurch wrote: I have a script that calls several subroutines, each of which makes a different figure. One of these routines makes lots of figures for use in a webpage, all of which are saved as they are made. When I call show() at the end of the script it is showing all the figures (as one might expect), but what I really want is only some of the figures to be brought up in the GUI. Is there a way of specifying which figures show() shows (I can't find anything on the webpage)? You can close some of the figures before calling show: pyplot.close(fig) or pyplot.close(fig_number) Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Making an Axis Label like a legend
On Tuesday 09 March 2010 21:10:49 Alex S wrote: Hmm I think I could do this with TextWithDash, but I can't manage to use it... I go: CumGasTxt = fig.text(0.5, 0.5, 'Cumulative Gas (MCF)', withdash=True) and it says AttributeError: Unknown property withdash. I tried changing fig to ax1, but although that doesn't spit out an error, it doesn't display anything. Does anyone know what I'm doing wrong? Thanks a lot, Alex Hi Alex, I cannot see the keyword argument 'withdash' for fig.text, but it does exists for ax.text (with ax being an subplot instance) at least since maplotlib version 0.99. Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] skipping mpl-axes-interaction during key_press_event's
On Wednesday 03 March 2010 19:10:10 Matthias Michler wrote: Hello list, I'd like to bring something back, which was discussed in sep-dec 2008 OSX 10.5 event.key bug, which was initially posted by James Schombert. Did I miss any development in this field? I tried to implement the latest proposal, which allows you to switch off the mpl-axes-interaction during key_press_event's for a specific axes using ax.set_auto_key_press(False) Therefore I changed the backend_bases.py and the axes.py (see attachement). If this is a suitable solution, one could switch off the mpl-axes-interaction during key_press_event's for all axes belonging to a button, slider, ... . I attached an updated version of my patch including the handling of key-events, which have no axes associated (patch against svn-HEAD and maintance branch). Kind regards, Matthias Index: lib/matplotlib/axes.py === --- lib/matplotlib/axes.py (revision 8178) +++ lib/matplotlib/axes.py (working copy) @@ -457,8 +457,8 @@ self._cachedRenderer = None self.set_navigate(True) self.set_navigate_mode(None) +self.set_auto_key_press(True) - if xscale: self.set_xscale(xscale) if yscale: @@ -2404,6 +2404,20 @@ self._navigate_mode = b +def set_auto_key_press(self, b): + +Enable / Disable processing of key-press events in +backend_bases.FigureManagerBase.key_press for this axes. + +self._auto_key_press = b + +def get_auto_key_press(self, b): + +Get current status of processing of key-press events in +backend_bases.FigureManagerBase.key_press for this axes. + +return self._auto_key_press + def start_pan(self, x, y, button): Called when a pan operation has started. Index: lib/matplotlib/backend_bases.py === --- lib/matplotlib/backend_bases.py (revision 8178) +++ lib/matplotlib/backend_bases.py (working copy) @@ -1883,6 +1883,9 @@ def key_press(self, event): +if event.inaxes and event.inaxes._auto_key_press is False: +return + # these bindings happen whether you are over an axes or not #if event.key == 'q': #self.destroy() # how cruel to have to destroy oneself! Index: lib/matplotlib/axes.py === --- lib/matplotlib/axes.py (revision 8178) +++ lib/matplotlib/axes.py (working copy) @@ -461,8 +461,8 @@ self._cachedRenderer = None self.set_navigate(True) self.set_navigate_mode(None) +self.set_auto_key_press(True) - if xscale: self.set_xscale(xscale) if yscale: @@ -2424,6 +2424,20 @@ self._navigate_mode = b +def set_auto_key_press(self, b): + +Enable / Disable processing of key-press events in +backend_bases.FigureManagerBase.key_press for this axes. + +self._auto_key_press = b + +def get_auto_key_press(self, b): + +Get current status of processing of key-press events in +backend_bases.FigureManagerBase.key_press for this axes. + +return self._auto_key_press + def start_pan(self, x, y, button): Called when a pan operation has started. Index: lib/matplotlib/backend_bases.py === --- lib/matplotlib/backend_bases.py (revision 8178) +++ lib/matplotlib/backend_bases.py (working copy) @@ -1677,6 +1677,9 @@ def key_press(self, event): +if event.inaxes and event.inaxes._auto_key_press is False: +return + # these bindings happen whether you are over an axes or not #if event.key == 'q': #self.destroy() # how cruel to have to destroy oneself! -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to insert a part of a plot in the same figure
On Thursday 04 March 2010 13:35:12 kamaleon wrote: Hey All, I have a fig, see attach image. I am plotting the number of infected nodes versus time. Time is running from 0 to 100. I need to insert a subplot in that figure that shows me the number of infected nodes for time running from 0 to 20 for example. If there is an example that can do the same thing I want please post it to me or tell me how I can do it in matplotlib. Cheers. http://old.nabble.com/file/p27780169/simbara-0%2B.41667-0-0.11-0.13-0.15-0. 18.png I would add an additional axes 'ax2' with different x/y-limits and plot all data to this axes. ax1 = axes() ax2 = axes([0.4, 0.4, 0.4, 0.4]) # rectangle [left, bottom, width, height] in normalized (0, 1) units ax1.plot(arange(100)) draw() ax2.plot(arange(100)) draw() ax2.set_xlim(0, 20) draw() Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to insert a part of a plot in the same figure
On Thursday 04 March 2010 17:11:54 kamaleon wrote: Thanks Matthias, this seems help me. But how to remove the xlabel, ylable and the tilte in the subplot? Cheers Matthias Michler wrote: On Thursday 04 March 2010 13:35:12 kamaleon wrote: [...] Hi , what do you mean by xlabel, ylabel and title? In my example these were not set. In case you set them, you can remove them using xlabel('') ylabel('') title('') or do you mean the ticks and tick-labels on the axes? These can be removed using xticks([ ]) ytick([ ]) Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Comma in LaTeX preamble
On Tuesday 02 March 2010 22:24:30 Heiko Bauke wrote: Hi, I use the text.latex.preamble rc setting to customize my plots. Everything works fine. However, a comma in this rc setting is interpreted as a new-line, thus, I wonder how can I create a LaTeX preamble that contains a comma? The statement matplotlib.rcParams['text.latex.preamble']=r\usepackage[garamond,sfscaled= false]{mathdesign} will produce a preamble with the two lines \usepackage[garamond sfscaled=false]{mathdesign} Which is not what I desire. Hi Heiko, in the matplotlibrc I read: #text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES # AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP # IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO. # preamble is a comma separated list of LaTeX statements # that are included in the LaTeX document preamble. Therefore it is assumed (in the rcsetup.py) that the given string needs to be devided into sub-strings, which are separated by commas. For your particular case - in my opinion - the solution is to provide a list of string(s) instead of a string matplotlib.rcParams['text.latex.preamble']=[r\usepackage[garamond,sfscaled=false] {mathdesign}] Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Artist tutorial different response
On Saturday 27 February 2010 07:39:59 David Arnold wrote: All, On: http://matplotlib.sourceforge.net/users/artists.html In the Axes Container section, you can see in what follows that I got some very different responses than what is shown on the page: In [1]: fig=figure() In [3]: ax=fig.add_subplot(111) In [4]: rect=matplotlib.patches.Rectangle((1,1),width=5,height=12) In [5]: print rect.get_axes() -- print(rect.get_axes()) None In [6]: print rect.get_transform() -- print(rect.get_transform()) BboxTransformTo(Bbox(array([[ 1., 1.], [ 6., 13.]]))) In [7]: ax.add_patch(rect) Out[7]: matplotlib.patches.Rectangle object at 0x2144db0 In [8]: print rect.get_axes() -- print(rect.get_axes()) Axes(0.125,0.1;0.775x0.8) In [9]: print rect.get_transform() -- print(rect.get_transform()) CompositeGenericTransform(BboxTransformTo(Bbox(array([[ 1., 1.], [ 6., 13.]]))), CompositeGenericTransform(TransformWrapper(BlendedAffine2D(IdentityTransfor m(),IdentityTransform())), CompositeAffine2D(BboxTransformFrom(TransformedBbox(Bbox(array([[ 0., 0.], [ 1., 1.]])), TransformWrapper(BlendedAffine2D(IdentityTransform(),IdentityTransform( ), BboxTransformTo(TransformedBbox(Bbox(array([[ 0.125, 0.1 ], [ 0.9 , 0.9 ]])), BboxTransformTo(TransformedBbox(Bbox(array([[ 0., 0.], [ 8., 6.]])), Affine2D(array([[ 80., 0., 0.], [ 0., 80., 0.], [ 0., 0., 1.]]) In [10]: print ax.transData --- print(ax.transData) CompositeGenericTransform(TransformWrapper(BlendedAffine2D(IdentityTransfor m(),IdentityTransform())), CompositeAffine2D(BboxTransformFrom(TransformedBbox(Bbox(array([[ 0., 0.], [ 1., 1.]])), TransformWrapper(BlendedAffine2D(IdentityTransform(),IdentityTransform( ), BboxTransformTo(TransformedBbox(Bbox(array([[ 0.125, 0.1 ], [ 0.9 , 0.9 ]])), BboxTransformTo(TransformedBbox(Bbox(array([[ 0., 0.], [ 8., 6.]])), Affine2D(array([[ 80., 0., 0.], [ 0., 80., 0.], [ 0., 0., 1.]] In [11]: print ax.get_xlim() --- print(ax.get_xlim()) (0.0, 1.0) In [12]: print ax.dataLim.get_bounds() --- print(ax.dataLim.get_bounds()) --- AttributeErrorTraceback (most recent call last) /Library/Frameworks/Python.framework/Versions/6.0.0/Examples/matplotlib-0.9 9.1.1/event_handling/ipython console in module() AttributeError: 'Bbox' object has no attribute 'get_bounds' In [13]: ax.autoscale_view() In [14]: print ax.get_xlim() --- print(ax.get_xlim()) (1.0, 6.0) In [15]: ax.figure.canvas.draw() David. Hi David, The biggest difference occurs for print ax.dataLim.get_bounds() because this method has been replaced by the property print ax.dataLim.bounds as is mentioned in the API-changes, but didn't find his way into this documentation. I attached a patch with modified documentation and further replacements of 'get_bounds' in current svn. Could any of the developers have a look at it and commit these changes or should a post the patch at the patch-tracker? Kind regards, Matthias Index: doc/users/artists.rst === --- doc/users/artists.rst (revision 8171) +++ doc/users/artists.rst (working copy) @@ -419,7 +419,7 @@ # and notice that the ax.add_patch method has set the axes # instance In [267]: print rect.get_axes() -Subplot(49,81.25) +Axes(0.125,0.1;0.775x0.8) # and the transformation has been set too In [268]: print rect.get_transform() @@ -434,7 +434,7 @@ (0.0, 1.0) # but the data limits have been updated to encompass the rectangle -In [271]: print ax.dataLim.get_bounds() +In [271]: print ax.dataLim.bounds (1.0, 1.0, 5.0, 12.0) # we can manually invoke the auto-scaling machinery Index: lib/matplotlib/finance.py === --- lib/matplotlib/finance.py (revision 8171) +++ lib/matplotlib/finance.py (working copy) @@ -597,8 +597,8 @@ maxy = max([volume for d, open, close, high, low, volume in quotes]) corners = (minpy, miny), (maxx, maxy) ax.update_datalim(corners) -#print 'datalim', ax.dataLim.get_bounds() -#print 'viewlim', ax.viewLim.get_bounds() +#print 'datalim', ax.dataLim.bounds +#print 'viewlim', ax.viewLim.bounds ax.add_collection(barCollection) ax.autoscale_view() Index: lib/matplotlib/patches.py === --- lib/matplotlib/patches.py (revision 8171) +++ lib/matplotlib/patches.py (working copy) @@ -1414,12 +1414,12 @@ pad = props.pop('pad', 4) pad = renderer.points_to_pixels(pad) bbox = artist.get_window_extent(renderer) -l,b,w,h = bbox.bounds -l-=pad/2. -b-=pad/2. -w+=pad -h+=pad -r = Rectangle(xy=(l,b), +
[Matplotlib-users] error, when calling ax.redraw_in_frame()
Hello list, I get an error, when calling ax.redraw_in_frame() (see below). I think this is due to the fact that the draw_wrapper expects args instead of kwargs for the draw of an Axes instance and therefore provide a patch, which adds an additional star. Could any of the developers have a look at it, please? Kind regards, Matthias # File textbox2_mod.py, line 37, in redraw self.ax.redraw_in_frame() File /scratch/michler/SOFT//lib/python2.5/site-packages/matplotlib/axes.py, line 1795, in redraw_in_frame self.draw(self._cachedRenderer, inframe=True) TypeError: draw_wrapper() got an unexpected keyword argument 'inframe' Index: lib/matplotlib/artist.py === --- lib/matplotlib/artist.py (revision 8171) +++ lib/matplotlib/artist.py (working copy) @@ -49,10 +49,10 @@ if artist.get_rasterized(): renderer.stop_rasterizing() -# the axes class has a second argument inframe for its draw method. -def draw_wrapper(artist, renderer, *kl): +# the axes class has a second keyword-argument inframe for its draw method. +def draw_wrapper(artist, renderer, **kl): before(artist, renderer) -draw(artist, renderer, *kl) +draw(artist, renderer, **kl) after(artist, renderer) # safe wrapping to exactly replicate anything we haven't overridden above -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Artist tutorial different response
On Wednesday 03 March 2010 17:02:58 John Hunter wrote: On Wed, Mar 3, 2010 at 9:56 AM, Matthias Michler matthiasmich...@gmx.net wrote: I attached a patch with modified documentation and further replacements of 'get_bounds' in current svn. Could any of the developers have a look at it and commit these changes or should a post the patch at the patch-tracker? The patch looks good -- could I trouble you to make a patch against the maintenance branch, which I can then merge into the trunk http://matplotlib.sourceforge.net/devel/coding_guide.html#svn-checkouts Thanks! JDH Hi John, I'm sorry. I didn't do this before and propably I won't manage it today. Which of the maintance branches do you mean? v0_91_maint/ v0_98_5_maint/ v0_99_maint/ or something completely different? By the way I think the link on devel/coding_guide.html to get svnmerge.py seems to be broken: http://svn.collab.net/repos/svn/trunk/contrib/client-side/svnmerge/svnmerge.py and in the attached patch doc_devel_coding_guide.patch I replaced it by: http://svn.apache.org/repos/asf/subversion/trunk/contrib/client-side/svnmerge/svnmerge.py Kind regards, Matthias Index: doc/devel/coding_guide.rst === --- doc/devel/coding_guide.rst (revision 8171) +++ doc/devel/coding_guide.rst (working copy) @@ -82,8 +82,8 @@ * install ``svnmerge.py`` in your PATH:: - wget http://svn.collab.net/repos/svn/trunk/contrib/client-side/\ - svnmerge/svnmerge.py + wget http://svn.apache.org/repos/asf/subversion/trunk/contrib/\ + client-side/svnmerge/svnmerge.py * get a svn checkout of the branch you'll be making bugfixes to and the trunk (see above) -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Artist tutorial different response
On Wednesday 03 March 2010 17:30:52 John Hunter wrote: On Wed, Mar 3, 2010 at 10:25 AM, Matthias Michler matthiasmich...@gmx.net wrote: On Wednesday 03 March 2010 17:02:58 John Hunter wrote: On Wed, Mar 3, 2010 at 9:56 AM, Matthias Michler matthiasmich...@gmx.net wrote: I attached a patch with modified documentation and further replacements of 'get_bounds' in current svn. Could any of the developers have a look at it and commit these changes or should a post the patch at the patch-tracker? The patch looks good -- could I trouble you to make a patch against the maintenance branch, which I can then merge into the trunk http://matplotlib.sourceforge.net/devel/coding_guide.html#svn-checkouts Thanks! JDH Hi John, I'm sorry. I didn't do this before and propably I won't manage it today. No need to apologize -- I appreciate you taking the time to make the patch. Since this bug affects the branch and the trunk, I'd like to see if fixed in both places since we plan to do a release of the maintenance branch first and then the trunk. The easiest way to do this in our workflow is to fix the branch and merge to the trunk. Hi John, no problem ... Which of the maintance branches do you mean? v0_91_maint/ v0_98_5_maint/ v0_99_maint/ or something completely different? v0_99_maint is the current maintenance branch/ I checked out https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint/ and included my changes of trunk as you can see in the attached patch. Furthermore I replaced a (minor) typo in lib/matplotlib/patches.py: - self.legnthA*scaleA) + self.lengthA*scaleA) Does this patch fulfill your needs? Kind regards, Matthias Index: doc/users/artists.rst === --- doc/users/artists.rst (revision 8171) +++ doc/users/artists.rst (working copy) @@ -419,7 +419,7 @@ # and notice that the ax.add_patch method has set the axes # instance In [267]: print rect.get_axes() -Subplot(49,81.25) +Axes(0.125,0.1;0.775x0.8) # and the transformation has been set too In [268]: print rect.get_transform() @@ -434,7 +434,7 @@ (0.0, 1.0) # but the data limits have been updated to encompass the rectangle -In [271]: print ax.dataLim.get_bounds() +In [271]: print ax.dataLim.bounds (1.0, 1.0, 5.0, 12.0) # we can manually invoke the auto-scaling machinery Index: lib/matplotlib/finance.py === --- lib/matplotlib/finance.py (revision 8171) +++ lib/matplotlib/finance.py (working copy) @@ -597,8 +597,8 @@ maxy = max([volume for d, open, close, high, low, volume in quotes]) corners = (minpy, miny), (maxx, maxy) ax.update_datalim(corners) -#print 'datalim', ax.dataLim.get_bounds() -#print 'viewlim', ax.viewLim.get_bounds() +#print 'datalim', ax.dataLim.bounds +#print 'viewlim', ax.viewLim.bounds ax.add_collection(barCollection) ax.autoscale_view() Index: lib/matplotlib/patches.py === --- lib/matplotlib/patches.py (revision 8171) +++ lib/matplotlib/patches.py (working copy) @@ -1383,12 +1383,12 @@ pad = props.pop('pad', 4) pad = renderer.points_to_pixels(pad) bbox = artist.get_window_extent(renderer) -l,b,w,h = bbox.bounds -l-=pad/2. -b-=pad/2. -w+=pad -h+=pad -r = Rectangle(xy=(l,b), +l, b, w, h = bbox.bounds +l -= pad/2. +b -= pad/2. +w += pad +h += pad +r = Rectangle(xy=(l, b), width=w, height=h, fill=fill, @@ -1407,8 +1407,8 @@ to test whether the artist is returning the correct bbox. -l,b,w,h = bbox.get_bounds() -r = Rectangle(xy=(l,b), +l, b, w, h = bbox.bounds +r = Rectangle(xy=(l, b), width=w, height=h, edgecolor=color, @@ -3174,7 +3174,7 @@ cos_t, sin_t = get_cos_sin(x1, y1, x0, y0) verticesA, codesA = self._get_bracket(x0, y0, cos_t, sin_t, self.widthA*scaleA, - self.legnthA*scaleA) + self.lengthA*scaleA) vertices_list.append(verticesA) codes_list.append(codesA) Index: lib/matplotlib/backends/backend_wxagg.py === --- lib/matplotlib/backends/backend_wxagg.py (revision 8171) +++ lib/matplotlib/backends/backend_wxagg.py (working copy) @@ -171,7 +171,7 @@ Convert the region of a wx.Image bounded by bbox to a wx.Bitmap. -l, b, width, height
[Matplotlib-users] skipping mpl-axes-interaction during key_press_event's
Hello list, I'd like to bring something back, which was discussed in sep-dec 2008 OSX 10.5 event.key bug, which was initially posted by James Schombert. Did I miss any development in this field? I tried to implement the latest proposal, which allows you to switch off the mpl-axes-interaction during key_press_event's for a specific axes using ax.set_auto_key_press(False) Therefore I changed the backend_bases.py and the axes.py (see attachement). If this is a suitable solution, one could switch off the mpl-axes-interaction during key_press_event's for all axes belonging to a button, slider, ... . Kind regards, Matthias Index: lib/matplotlib/axes.py === --- lib/matplotlib/axes.py (revision 8171) +++ lib/matplotlib/axes.py (working copy) @@ -457,8 +457,8 @@ self._cachedRenderer = None self.set_navigate(True) self.set_navigate_mode(None) +self.set_auto_key_press(True) - if xscale: self.set_xscale(xscale) if yscale: @@ -2404,6 +2404,20 @@ self._navigate_mode = b +def set_auto_key_press(self, b): + +Enable / Disable processing of key-press events in +backend_bases.FigureManagerBase.key_press for this axes. + +self._auto_key_press = b + +def get_auto_key_press(self, b): + +Get current status of processing of key-press events in +backend_bases.FigureManagerBase.key_press for this axes. + +return self._auto_key_press + def start_pan(self, x, y, button): Called when a pan operation has started. Index: lib/matplotlib/backend_bases.py === --- lib/matplotlib/backend_bases.py (revision 8171) +++ lib/matplotlib/backend_bases.py (working copy) @@ -1883,6 +1883,9 @@ def key_press(self, event): +if event.inaxes._auto_key_press is False: +return + # these bindings happen whether you are over an axes or not #if event.key == 'q': #self.destroy() # how cruel to have to destroy oneself! -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Cannot draw bar chart with log scale
On Thursday 25 February 2010 15:56:31 afancy wrote: Hi, I have some difficulty to use the log scale on bar chart. Could anybody help me, thanks in advace. Regards, afancy from matplotlib.font_manager import FontProperties data=((0.014, 0.512, 0.015, 0.161, 1.177, 6.793, 0.089, 1.495, 25.65, 0.014, 0.045, 0.052, 5.423), (0.529, 0.612, 0.855, 0.178, 1.432, 6.43, 41.311, 1.62, 71.012, 1.59, 0.271, 0.066, 4.721), (0.493, 834.351, 0.156, 743.193,0.428, 84.101, 1058.062,8.652, 1023,0.168, 7.101, 8.135, 152.646), (118.90,2035.35, 89.35, 15.402, 10.856,110.049,3024.42, 8054.74,5214.36, 5.539, 11.539, 515.632,150.411) ) rects=[] xticks=[] patterns = ('/','x', '\\','o') colors=['r','b','y', 'g'] fig = figure() ax=fig.add_subplot(111) ax.set_yscale('log') ax.set_ylim(1e-4, 1e5) width=0.1 for q in range(13): for n in range(4): l = q+width*n h = data[n][q] w = width rect, = ax.bar(l, h, w, bottom=0, fill=False, hatch=patterns[n], log=True) draw() Hi if I replace bottom=0 with bottom=10**-3 in your script I see bars. Kind regards, Matthias Michler -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Looping through all the built-in colormaps
On Wednesday 24 February 2010 00:45:56 David Goldsmith wrote: Hi! I'm trying to loop through all the built-in colormaps, applying each to an image before printing it to a file, then moving on to the next one. from matplotlib import cm for cmap in dir(cm): # cmap in cm doesn't work 'cause cm is a module ax.imshow(image, cmap) canvas.print_figure('image_'+cmap) works until cmap == 'LUTSIZE', which evaluates to an integer and thus raises an exception. I tried putting it in a try/except: for cmap in dir(cm): try: ax.imshow(image, cmap) canvas.print_figure('image_'+cmap) except: pass but despite this, after 'LUTSIZE', every cmap - even valid ones - also raises the exception, and thus doesn't get used. So I tried just by-passing cmap == 'LUTSIZE' (in the obvious way), but then encountered cmap == 'ScalarMapable', which resulted in the same subsequent behavior as 'LUTSIZE'. At that point I decided I should try a positive filter, so I figured out that cmaps are instances of matplotlib.colors.LinearSegmentedColormap (which I imported as LSC) and tried adding an if isinstance(cmap, LSC), but of course that didn't work, 'cause the elements of dir(cm) are strings, not LSC's. At this point I've decided I've wasted too much time trying to figure this out on my own, so: 0) is there some elegant way to do what I want to do? 1) why doesn't this: for cmap in dir(cm): try: ax.imshow(image, cmap) canvas.print_figure('image_'+cmap) except: pass work (i.e., simply bypass those elements of dir(cm) which cause imshow to raise an exception, but then continue on as if nothing had happened)? Is this a bug? Thanks! DG Hi, some time ago somebody proposed an example on the list to circle through all possible colormaps. In this time cm had an attribute cm.cmapnames, which hold all these names, but nowerdays (svn-HEAD) this attribute has be removed and in my opinion 'cm.cmap_d.keys()' is an appropriate replacement for this. In your example, you cycle through all tools/functions/variables of the cm-module and therefore encounter non-cmaps (like LUTSIZE, ...). To make my point: I think you have to replace for cmap in dir(cm): with for i in cm.cmap_d.keys(): Kind regards, Matthias -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Assigning k key for xscaling
Hi list, Hi Gökhan, I once more would like to say that I like the 2 new features introduced by Gökhan (key 'k' for xscaling and the generalized handling of the key-mapping, which allows the user to choose its prefered key for a certain task) and I'd like to see this in matplotlib. I attached a patch (against todays svn) of my final version, which is a slightly modified version of Gökhans patch. If anybody could test it and comments on this I'd be happy. Otherwise I will place the patch on the patch tracker in (let's say) a week. Thanks in advance for any help in order to bring this into matplotlib. Kind regards, Matthias On Tuesday 02 February 2010 14:05:52 Matthias Michler wrote: Hi Gökhan, I'm sorry I didn't had the time to look into your patch in the last days. Today I did have a look at it and in my opinion you did a great job - Thanks! The point is that I'm not a developer and therefore cannot commit it right away ;-) . Although it is great stuff I tried to even improve it. Attached you find my svn-diff of the backend_bases.py, where I tried to get rid of the different handling of *3* keys for home and *1* for save etc. I converted all key-maps into lists and therefore the number of keys doesn't matter. With that I can do also xscale : L, k in my matplotlibrc and allow foGökhanr both of our favorite keys for the toggling of the xscale ;-) Concerning the names of the variables you find some changes in the attached patch, which are not yet complete in my opinion, but I didn't want to spoil your lines to much. If I have to decide between short and meaningful variable names, I prefer meaningful at least if they don't blow up to 80 chars ;-) ... In my opinion your next patch should be a part of matplotlibs svn, but as I mentioned above I'm just a user. In case I can help you somehow in bringing up this patch, don't hesitate to write again and hopefully I have the time to help. Kind regards, Matthias On Friday 29 January 2010 20:22:20 Gökhan Sever wrote: My initial patch is ready for your review. I tested with latest svn and customized key-mapping (from matplotlibrc) is working correctly. Please review, and let me know if there would be any better solution, variable naming, placing etc.. I can also update the http://matplotlib.sourceforge.net/users/navigation_toolbar.html accordingly. On Mon, Jan 25, 2010 at 12:58 PM, Gökhan Sever gokhanse...@gmail.comwrote: Hello, I could these keys into rcsetup.py file as well as matplotlibrc.template and update backend_bases.py accordingly. And add some documentation reflecting the changes made. # Event keys to interact with figures/plots via keyboard fullscreen : 'f' home : 'h' reset : 'r' back : 'c' forward : 'v' pan : 'p' zoom : 'o' save : 's' grid : 'g' yscale : 'l' xscale : 'k' *Notes:* Matthias, leaving values as empty will remove the key short-cut. Don't understand exactly what 'a' does? f doesn't toggle full-screen --using qt4agg backend. There are a couple function duplicates. (eg. back with 'c' and left and backspace keys. How can represent them? Create a list inside the dictionary? back = ['c', 'left', 'backspace'] 'o' seems like unnecessary. Since you have to select an area using mouse. 's' doesn't behave correctly here. Shouldn't it bring the save dialog? Instead I am getting: TypeError: save_figure() takes exactly 1 argument (2 given) On Mon, Jan 25, 2010 at 8:32 AM, Matthias Michler matthiasmich...@gmx.net wrote: Hi Gökhan, I just wanted to discuss the key, because I think this patch should be part of matplotlib and not only of individual users. I think it is worth be be added to the mpl-tracker at http://sourceforge.net/tracker/?group_id=80706 or maybe one of the developers has the time to commit this small change? I think your idea about key-mappings in the matplotlib-rc is a good option to customize keyboard short cuts and even remove short-cuts which aren't of intrest for the individual user. Furthermore the latter yields space for keyboard shortcuts, which are used in one's own program. Kind regards, Matthias On Friday 22 January 2010 16:57:22 Gökhan Sever wrote: It is very simple to change key-assignment. Take a look at the backend_bases.py code (search for event.key instances) : elif event.key == 'L': I was thinking to move y-scaling to y and x-scaling to x but x and y are assigned to something else ( http://matplotlib.sourceforge.net/users/navigation_toolbar.html) For me toggling k is simpler for me than doing Shift-L. Maybe these options could be provided in the matplotlibrc file. Users can make their key mapping based on their choice. That requires some more coding :) On Fri, Jan 22
Re: [Matplotlib-users] Assigning k key for xscaling
On Wednesday 17 February 2010 15:28:24 John Hunter wrote: On Wed, Feb 17, 2010 at 8:08 AM, Matthias Michler matthiasmich...@gmx.net wrote: Hi list, Hi Gökhan, I once more would like to say that I like the 2 new features introduced by Gökhan (key 'k' for xscaling and the generalized handling of the key-mapping, which allows the user to choose its prefered key for a certain task) and I'd like to see this in matplotlib. I attached a patch (against todays svn) of my final version, which is a slightly modified version of Gökhans patch. If anybody could test it and comments on this I'd be happy. Otherwise I will place the patch on the patch tracker in (let's say) a week. Thanks in advance for any help in order to bring this into matplotlib. Hi -- these look like useful changes. In most of matplotlib rc we have a namespace for the rc keys, so I prefer something like keymap.fullscreen : f # toggling keymap.home : h, r, home# home or reset mnemonic Also, could you include in your patch a diff against mpl/doc/users/navigation_toolbar.rst documenting the changes. Also, I'm not sure you need +# to get a common standard we move all keys for each action into a list +for key in [fullscreen_keys, home_keys, back_keys, forward_keys, +pan_keys, zoom_keys, save_keys, grid_keys, +toggle_xscale_keys, toggle_yscale_keys, all]: +if type(key) is not list: +key = list(key) + If you setup your validate func properly in rcsetup, you can guarantee that each of these keymap.* entries will be a list of strings, even those changes interactively from the prompt. So I suggest changing each of these key entries to have a validate_stringlist validator and then you won't need this check. Hi John, thanks a lot for taking the time to go through this patch. I tried to incorporate you remarks and attached a new patch. The most difficult task is about the documentation 'mpl/doc/users/navigation_toolbar.rst', because I'm not sure what is needed and I not familiar with the used programming language. Kind regards, Matthias Index: matplotlibrc.template === --- matplotlibrc.template (revision 8139) +++ matplotlibrc.template (working copy) @@ -360,3 +360,20 @@ # from matplotlib import verbose. #verbose.level : silent # one of silent, helpful, debug, debug-annoying #verbose.fileo : sys.stdout # a log filename, sys.stdout or sys.stderr + +# Event keys to interact with figures/plots via keyboard. +# Customize these settings according to your needs. +# Leave the field(s) empty if you don't need a key-map. (i.e., fullscreen : '') + +#keymap.fullscreen : f # toggling +#keymap.home : h, r, home# home or reset mnemonic +#keymap.back : left, c, backspace# forward / backward keys to enable +#keymap.forward : right, v # left handed quick navigation +#keymap.pan : p # pan mnemonic +#keymap.zoom : o # zoom mnemonic +#keymap.save : s # saving current figure +#keymap.grid : g # switching on/off a grid in current axes +#keymap.yscale : l # toggle scaling of y-axes ('log'/'linear') +#keymap.xscale : L, k# toggle scaling of x-axes ('log'/'linear') +#keymap.all_axes : a # enable all axes + Index: lib/matplotlib/backend_bases.py === --- lib/matplotlib/backend_bases.py (revision 8139) +++ lib/matplotlib/backend_bases.py (working copy) @@ -1888,50 +1888,85 @@ #self.destroy() # how cruel to have to destroy oneself! #return -if event.key == 'f': +# Load key-mappings from your matplotlibrc file. +fullscreen_keys = rcParams['keymap.fullscreen'] +home_keys = rcParams['keymap.home'] +back_keys = rcParams['keymap.back'] +forward_keys = rcParams['keymap.forward'] +pan_keys = rcParams['keymap.pan'] +zoom_keys = rcParams['keymap.zoom'] +save_keys = rcParams['keymap.save'] +grid_keys = rcParams['keymap.grid'] +toggle_yscale_keys = rcParams['keymap.yscale'] +toggle_xscale_keys = rcParams['keymap.xscale'] +all = rcParams['keymap.all_axes'] + +# toggle fullscreen mode (default key 'f') +if event.key in fullscreen_keys: self.full_screen_toggle() -# *h*ome or *r*eset mnemonic -elif event.key == 'h' or event.key == 'r' or event.key == home: +# home or reset mnemonic (default key 'h', 'home' and 'r') +elif event.key in home_keys: self.canvas.toolbar.home() -# c and v to enable left handed quick navigation -elif event.key == 'left' or event.key == 'c' or event.key
Re: [Matplotlib-users] forcing a plot to appear
Hi Ken, On Monday 15 February 2010 20:35:06 Ken Dere wrote: Hi, I am trying to develop an application that I can run inside the ipython shell. One of my methods creates a plot, asks the user to make a choice based on that plot, and then creates another plot that displays the chosen set of information. If the choices are made with a qt or wx dialogue, everything goes fine. If I try to get the choice by asking the user to type the information into the shell, neither plot appears until after the choice is made. I have tried show() and draw() but neither make any difference. I attached a script that allows to input a number via raw_input (after the first figure appeared) and than opens up a second figure. I hope the goes towards your needs. Kind regards, Matthias let_a_plot_appear.py Description: application/python -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to draw a rectangle using event handler ?
Hi Yagua, On Friday 12 February 2010 17:04:27 Yagua Rovi wrote: Hello world! I am displaying on my screen a set of data corresponding to points defined by a longitude and latitude. The display is fine with the command imshow (mydata ,...) I would like now associate to the application a callback that draw a rectangle on two consecutive left mouse's button press defined by its two opposite vertices. (also returns points) and a right click button that erases the rectangle. Why don't you want for select the rectangle using the rectangle selector? I attached an example (modified version of example 'rectangle_selector.py') showing its usage. You can delete lines using the key 'd' or 'D'. Furthermore I attached a script, which uses button_press_event s as you proposed above. I hope at least one of the examples helps you. Kind regards, Matthias draw_rectangle_using_button_press_events.py Description: application/python draw_rectangle_using_rectangle_selector.py Description: application/python -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] tick labels in colorbar?
On Monday 15 February 2010 09:28:10 Nico Schlömer wrote: Hi, thanks for the suggestion. ax.set_xticks((-pi,pi)) ax.set_xticklabels(('$-\pi$','$\pi$')) I guess color bars are a little special in the sense that AttributeError: Colorbar instance has no attribute 'set_yticklabels' The tick positions are given not by set_yticks either, but as an option pylab.colorbar(ticks=(-pi,0,pi)) at the instatiation of the bar. It would indeed be very handy if the bars acted like axes. Hi Nico, nontheless you can use the axes-method to display your preferred labels. The colorbar has its axes as attribute 'ax' (see also my small example below): cb.ax.set_yticklabels((r'$-\pi$', '0', r'$\pi$')) Kind regards, Matthias --- import matplotlib as mpl mpl.rc('text', usetex=True) import matplotlib.pyplot as plt import numpy as np ax = plt.axes() plt.imshow(np.reshape(np.pi*np.arange(-2, 3, 0.5), (2, 5))) cb = plt.colorbar() cb.set_ticks((-np.pi, 0.0, np.pi)) cb.ax.set_yticklabels((r'$-\pi$', '0', r'$\pi$')) plt.show() -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Maximize plotwindow hot to plot figure by figure?
On Friday 12 February 2010 00:36:41 zxc wrote: 2 Problems: 1. How is it possible to maximize the window of the plot? If the window is open and you are in the mainloop ypu can press ' f ' for fullscreen mode. Furthmore you can modify the figure-size by figure(figsize=(16, 8)) 2. First I want to plot only figure 0, after 5 seconds figure 0 has to be closed and figure 1 to be shown. Any suggestions? for the second point I attached an example which uses an earlier 'draw' to actually show the first figure in interactive mode. Furthermore I proposed an example without generating new figures and reusing one figure. Kind regards, Matthias from pylab import * import time ion() figure(0) plot([1,2,3]) figure(1) plot([10, 20, 30]) figure(0) plot([4, 5, 6]) figure(1) plot([40, 50, 60]) draw(0) time.sleep(5) close() draw(1) show() figure_by_figure.py Description: application/python -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Selectable contour(f) divisions
Hi Bruce, why don't you use contour as in the following ;-) contour(X,Y,Z,V) # - draw contour lines at the values specified in sequence *V* like in x, y = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 50)) z = x**4 - x**2 + np.sin(y) contour(x, y, z, [-0.2, 0.0, 0.2, 0.4, 0.6, 0.8]) Kind regards, Matthias On Thursday 11 February 2010 21:58:15 Bruce Ford wrote: In using the contour as in: contour(X,Y,Z,N) N is a number of automatically chosen levels. I would like to contour based on data divisions. For instance, perhaps I'd like to use a contour or color-fill (contourf) every 2 units. I'm not seeing how to accomplish this. Any points in the right direction would be appreciated. Thanks! Bruce -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Selectable contour(f) divisions
On Friday 12 February 2010 15:11:17 Bruce Ford wrote: Thanks for this. I didn't realize that N could be an array and contour would know that these are the levels desired. I found similar in an example, but not in the contour documentation. Just a remark: I use the help of IPython to investigate the doc-strings of matplotlib-functions. The input contour? tells me :: contour(Z,V) contour(X,Y,Z,V) draw contour lines at the values specified in sequence *V* Kind regards, Matthias Thanks so much! Bruce On Fri, Feb 12, 2010 at 7:29 AM, Matthias Michler matthiasmich...@gmx.net wrote: Hi Bruce, why don't you use contour as in the following ;-) contour(X,Y,Z,V) # - draw contour lines at the values specified in sequence *V* like in x, y = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 50)) z = x**4 - x**2 + np.sin(y) contour(x, y, z, [-0.2, 0.0, 0.2, 0.4, 0.6, 0.8]) Kind regards, Matthias On Thursday 11 February 2010 21:58:15 Bruce Ford wrote: In using the contour as in: contour(X,Y,Z,N) N is a number of automatically chosen levels. I would like to contour based on data divisions. For instance, perhaps I'd like to use a contour or color-fill (contourf) every 2 units. I'm not seeing how to accomplish this. Any points in the right direction would be appreciated. Thanks! Bruce -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] his problems...
On Tuesday 09 February 2010 17:38:18 Nick Schurch wrote: HI all, I've been using matplotlip for a while now but mainly for line plots, scatter plots and the odd dendrogram. I recently tried plotting a histogram (of a binomial function) and encountered a problem. So I though I'd try the extremely simple example set on the front of the matplotlib page and heres what I got: Python 2.4.3 (#1, Sep 3 2009, 15:37:12) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 Type help, copyright, credits or license for more information. from pylab import randn, hist x = randn(1) hist(x, 100) Traceback (most recent call last): File stdin, line 1, in ? File /usr/lib/python2.4/site-packages/matplotlib/pyplot.py, line 1633, in hist ret = gca().hist(*args, **kwargs) File /usr/lib/python2.4/site-packages/matplotlib/axes.py, line 5060, in hist align=align, log=log) File /usr/lib/python2.4/site-packages/matplotlib/axes.py, line 3253, in bar assert len(height)==nbars, argument 'height' must be %d or scalar % nbars AssertionError: argument 'height' must be 101 or scalar Any idea why this isn't working? I have matplotlib v0.91.2 - will updating to 0.99 solve the problem? Hi, I'm using Python 2.5.2 (r252:60911, Jan 20 2010, 21:48:48) [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2 Type help, copyright, credits or license for more information. from pylab import randn, hist, show x = randn(1) hist(x, 100) show() import matplotlib matplotlib.__version__ '0.91.2' and get a nice figure with a 100-bins histogram. I don't know what's going wrong with your installation. Kind regards, Matthias -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] help with view_limits
Hi Che, I think turning off autoscaling is what you need: import matplotlib.pyplot as plt ax = plt.subplot(111, autoscaley_on=False, ylim=(0, 100)) plt.plot([1, 2], [-40, 40]) plt.show() Kind regards, Matthias On Monday 08 February 2010 20:49:50 C M wrote: I'd like to set the ticks on the y axis such that they do not display anything lower than 0, even if part of the graph below 0 is visible. I tried to do this with ylocator = AutoLocator() ylocator.view_limits(0, 100) self.subplot.yaxis.set_major_locator(ylocator) but it is not changing anything. How can I do this? Thank you, Che -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Assigning k key for xscaling
Hi Gökhan, I'm sorry I didn't had the time to look into your patch in the last days. Today I did have a look at it and in my opinion you did a great job - Thanks! The point is that I'm not a developer and therefore cannot commit it right away ;-) . Although it is great stuff I tried to even improve it. Attached you find my svn-diff of the backend_bases.py, where I tried to get rid of the different handling of *3* keys for home and *1* for save etc. I converted all key-maps into lists and therefore the number of keys doesn't matter. With that I can do also xscale : L, k in my matplotlibrc and allow for both of our favorite keys for the toggling of the xscale ;-) Concerning the names of the variables you find some changes in the attached patch, which are not yet complete in my opinion, but I didn't want to spoil your lines to much. If I have to decide between short and meaningful variable names, I prefer meaningful at least if they don't blow up to 80 chars ;-) ... In my opinion your next patch should be a part of matplotlibs svn, but as I mentioned above I'm just a user. In case I can help you somehow in bringing up this patch, don't hesitate to write again and hopefully I have the time to help. Kind regards, Matthias On Friday 29 January 2010 20:22:20 Gökhan Sever wrote: My initial patch is ready for your review. I tested with latest svn and customized key-mapping (from matplotlibrc) is working correctly. Please review, and let me know if there would be any better solution, variable naming, placing etc.. I can also update the http://matplotlib.sourceforge.net/users/navigation_toolbar.html accordingly. On Mon, Jan 25, 2010 at 12:58 PM, Gökhan Sever gokhanse...@gmail.comwrote: Hello, I could these keys into rcsetup.py file as well as matplotlibrc.template and update backend_bases.py accordingly. And add some documentation reflecting the changes made. # Event keys to interact with figures/plots via keyboard fullscreen : 'f' home : 'h' reset : 'r' back : 'c' forward : 'v' pan : 'p' zoom : 'o' save : 's' grid : 'g' yscale : 'l' xscale : 'k' *Notes:* Matthias, leaving values as empty will remove the key short-cut. Don't understand exactly what 'a' does? f doesn't toggle full-screen --using qt4agg backend. There are a couple function duplicates. (eg. back with 'c' and left and backspace keys. How can represent them? Create a list inside the dictionary? back = ['c', 'left', 'backspace'] 'o' seems like unnecessary. Since you have to select an area using mouse. 's' doesn't behave correctly here. Shouldn't it bring the save dialog? Instead I am getting: TypeError: save_figure() takes exactly 1 argument (2 given) On Mon, Jan 25, 2010 at 8:32 AM, Matthias Michler matthiasmich...@gmx.net wrote: Hi Gökhan, I just wanted to discuss the key, because I think this patch should be part of matplotlib and not only of individual users. I think it is worth be be added to the mpl-tracker at http://sourceforge.net/tracker/?group_id=80706 or maybe one of the developers has the time to commit this small change? I think your idea about key-mappings in the matplotlib-rc is a good option to customize keyboard short cuts and even remove short-cuts which aren't of intrest for the individual user. Furthermore the latter yields space for keyboard shortcuts, which are used in one's own program. Kind regards, Matthias On Friday 22 January 2010 16:57:22 Gökhan Sever wrote: It is very simple to change key-assignment. Take a look at the backend_bases.py code (search for event.key instances) : elif event.key == 'L': I was thinking to move y-scaling to y and x-scaling to x but x and y are assigned to something else ( http://matplotlib.sourceforge.net/users/navigation_toolbar.html) For me toggling k is simpler for me than doing Shift-L. Maybe these options could be provided in the matplotlibrc file. Users can make their key mapping based on their choice. That requires some more coding :) On Fri, Jan 22, 2010 at 1:59 AM, Matthias Michler matthiasmich...@gmx.netwrote: Hi Gökhan, Hi list members, This is really a missing feature in matplotlib in my opinion and it's great that you took the time to make an suggestion, but I would prefer capital L for the xaxis-scaling like gnuplot although I'm not sure this is possible. What do you and other list members think about that? Kind regards, Matthias On Thursday 21 January 2010 19:45:37 Gökhan Sever wrote: Hello, l key does the log - linear scaling for y-axis. I have made a minor change to use k for x-axis scaling. Patch added. Feel free to add if you find it useful. Index: lib/matplotlib/backend_bases.py === --- lib
[Matplotlib-users] problem with Axes3D.cla
Hello list, I encounter a problem with the method Axes3D.cla. I'm running the follwing lines in ipython -pylab from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = Axes3D(fig) draw() Then I do have a Axes3D, in which I can perform zooming with left and right mouse button. If I now call ax.cla() to clear the axes the screen is freezed and I don't know how to leave this state enabling again zooming. Thanks in advance for any hints. Kind regards, Matthias -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plot coordinates points
Hi, do you mean a single point with coordinates x and y like plot([1.2], [2.5], marker='+') Regards, Matthias On Wednesday 27 January 2010 17:26:39 franck kalala wrote: Hey all how to plot a point coordinates in matplotlib? I want for example to plot the point of coordinates x=1.2,y=2.5 Cheers -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] defining/saving contours without plotting
Hi Jon, one thing you can do is to get the (x, y)-values of the calculated contourlines: cs = plt.contour(z, levels=[0]) a = cs.collections[0].get_paths()[0].vertices # - array of shape (..., 2) hold x and y in first and second column I don't know wheter this is the best way, but at least for me it works. Kind regards, Matthias On Wednesday 27 January 2010 15:14:27 Jonathan Slavin wrote: To matplotusers: I want to create a plot that has an image and overplots contours, but the contours are defined relative to different data from that plotted in the image. Is there a way to save contour line data rather than plot it. It just occurred to me a way of creating the plot -- but I'm still interested in a way to save contour data. Jon -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Newb question - multiple colors in bar chart
Hi Jeff, you can do something like the following and specify the color for each bar by providing a list of colors for the keyword argument 'color'. import numpy as np import matplotlib.pyplot as plt # generate some data left = np.arange(6) height = np.random.uniform(size=6) # plot 3 blue and 3 red bars: plt.bar(left, height, color=['blue']*3+ ['red']*3) plt.show() You second way could be provided by the color list ['red', '0.5']*3 = ['red', '0.5', 'red', '0.5', 'red', '0.5'] Kind regards, Matthias On Saturday 23 January 2010 16:36:36 Jeff Layton wrote: Good morning, I hate to ask such a newbie question but I am a newb with matplotlib :) I want to create a bar chart with, for example, 6 bars. I want the first 3 bars to be one color and the second 3 bars to be another color. I'm not entirely sure how to do this - any suggestions? Alternatively, I would like to create 6 bars where every other bar is a different color. For example, gray, red, gray, red, gray, red. Any suggestions on this? TIA! Jeff -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Assigning k key for xscaling
Hi Gökhan, I just wanted to discuss the key, because I think this patch should be part of matplotlib and not only of individual users. I think it is worth be be added to the mpl-tracker at http://sourceforge.net/tracker/?group_id=80706 or maybe one of the developers has the time to commit this small change? I think your idea about key-mappings in the matplotlib-rc is a good option to customize keyboard short cuts and even remove short-cuts which aren't of intrest for the individual user. Furthermore the latter yields space for keyboard shortcuts, which are used in one's own program. Kind regards, Matthias On Friday 22 January 2010 16:57:22 Gökhan Sever wrote: It is very simple to change key-assignment. Take a look at the backend_bases.py code (search for event.key instances) : elif event.key == 'L': I was thinking to move y-scaling to y and x-scaling to x but x and y are assigned to something else ( http://matplotlib.sourceforge.net/users/navigation_toolbar.html) For me toggling k is simpler for me than doing Shift-L. Maybe these options could be provided in the matplotlibrc file. Users can make their key mapping based on their choice. That requires some more coding :) On Fri, Jan 22, 2010 at 1:59 AM, Matthias Michler matthiasmich...@gmx.netwrote: Hi Gökhan, Hi list members, This is really a missing feature in matplotlib in my opinion and it's great that you took the time to make an suggestion, but I would prefer capital L for the xaxis-scaling like gnuplot although I'm not sure this is possible. What do you and other list members think about that? Kind regards, Matthias On Thursday 21 January 2010 19:45:37 Gökhan Sever wrote: Hello, l key does the log - linear scaling for y-axis. I have made a minor change to use k for x-axis scaling. Patch added. Feel free to add if you find it useful. -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Assigning k key for xscaling
Hi Gökhan, On Monday 25 January 2010 20:04:14 Gökhan Sever wrote: Constrain pan/zoom to x axis hold *x* Constrain pan/zoom to y axis hold *y* I don't have these in my backend_bases.py file. Are these working on your system? Yes they do, but only for pan/zoom-mode and not for rect zoom. Kind regards, Matthias On Mon, Jan 25, 2010 at 12:58 PM, Gökhan Sever gokhanse...@gmail.comwrote: Hello, I could these keys into rcsetup.py file as well as matplotlibrc.template and update backend_bases.py accordingly. And add some documentation reflecting the changes made. # Event keys to interact with figures/plots via keyboard fullscreen : 'f' home : 'h' reset : 'r' back : 'c' forward : 'v' pan : 'p' zoom : 'o' save : 's' grid : 'g' yscale : 'l' xscale : 'k' *Notes:* Matthias, leaving values as empty will remove the key short-cut. Don't understand exactly what 'a' does? f doesn't toggle full-screen --using qt4agg backend. There are a couple function duplicates. (eg. back with 'c' and left and backspace keys. How can represent them? Create a list inside the dictionary? back = ['c', 'left', 'backspace'] 'o' seems like unnecessary. Since you have to select an area using mouse. 's' doesn't behave correctly here. Shouldn't it bring the save dialog? Instead I am getting: TypeError: save_figure() takes exactly 1 argument (2 given) On Mon, Jan 25, 2010 at 8:32 AM, Matthias Michler matthiasmich...@gmx.net wrote: Hi Gökhan, I just wanted to discuss the key, because I think this patch should be part of matplotlib and not only of individual users. I think it is worth be be added to the mpl-tracker at http://sourceforge.net/tracker/?group_id=80706 or maybe one of the developers has the time to commit this small change? I think your idea about key-mappings in the matplotlib-rc is a good option to customize keyboard short cuts and even remove short-cuts which aren't of intrest for the individual user. Furthermore the latter yields space for keyboard shortcuts, which are used in one's own program. Kind regards, Matthias On Friday 22 January 2010 16:57:22 Gökhan Sever wrote: It is very simple to change key-assignment. Take a look at the backend_bases.py code (search for event.key instances) : elif event.key == 'L': I was thinking to move y-scaling to y and x-scaling to x but x and y are assigned to something else ( http://matplotlib.sourceforge.net/users/navigation_toolbar.html) For me toggling k is simpler for me than doing Shift-L. Maybe these options could be provided in the matplotlibrc file. Users can make their key mapping based on their choice. That requires some more coding :) On Fri, Jan 22, 2010 at 1:59 AM, Matthias Michler matthiasmich...@gmx.netwrote: Hi Gökhan, Hi list members, This is really a missing feature in matplotlib in my opinion and it's great that you took the time to make an suggestion, but I would prefer capital L for the xaxis-scaling like gnuplot although I'm not sure this is possible. What do you and other list members think about that? Kind regards, Matthias On Thursday 21 January 2010 19:45:37 Gökhan Sever wrote: Hello, l key does the log - linear scaling for y-axis. I have made a minor change to use k for x-axis scaling. Patch added. Feel free to add if you find it useful. -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Gökhan -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] vector EPS
Hey Matt, Hello list, I'm sorry, I'm not an expert in eps-graphics. For me the final pics look good and I have no idea what is different between matplotlib eps-files and eps-files generated somewhere else. Maybe someone has an idea. Kind regards, Matthias On Thursday 21 January 2010 10:37:32 Matthew Czesarski wrote: Hey Matthias, Oh, I can make eps files themselves no problem... In as much as I don't really understand the difference between vector and raster graphics, I was told to submit 89mm images (I can make them 89mm, fortunately...), with text that can be resized by the graphics department. For which I understand it should not be rasterized at all, but the fonts, sizes, coordinates, etc should be embedded in the postscript. I.e. not the way MPL produces .eps. Does this sound right to you? Thanks, Matt -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Assigning k key for xscaling
Hi Gökhan, Hi list members, This is really a missing feature in matplotlib in my opinion and it's great that you took the time to make an suggestion, but I would prefer capital L for the xaxis-scaling like gnuplot although I'm not sure this is possible. What do you and other list members think about that? Kind regards, Matthias On Thursday 21 January 2010 19:45:37 Gökhan Sever wrote: Hello, l key does the log - linear scaling for y-axis. I have made a minor change to use k for x-axis scaling. Patch added. Feel free to add if you find it useful. -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] mplot3d scatter3d marker sizes?
Hi Erik, I can reproduce your finding on my site. Maybe this kind of specifying the coloring is not yet fully supported. I think Reinier Heeres is the one how knows almost everything about mplot3D - maybe he can comment on this. Kind regards, Matthias On Wednesday 20 January 2010 00:14:39 Erik Tollerud wrote: Apparently it wasn't recent enough - I updated to the latest svn and now they are sizing properly - thanks! Another oddity I've noticed, though - if I do ax.scatter3D(x,y,z,s=30*rand(20),c=rand(20)) I would expect to see the points colored based on a color map for the supplied scalar values. Instead, they all appear white. If I do rand(20,3) , it gives random colors, but that's specifying r,g,b values instead of scalar mapping. Is there a way to do the color mapping directly as in the 2D scatter? (If not, it's of course possible to manually apply the mapping - just less convinient) On Mon, Jan 18, 2010 at 11:49 PM, Matthias Michler matthiasmich...@gmx.net wrote: Hi Erik, with current svn I see markers of different size. What version of matplotlib you are using? Kind regards, Matthias On Monday 18 January 2010 21:38:25 Erik Tollerud wrote: Is there a way to change the sizes of scatter plot markers for mplot3d.Axes3D.scatter3d ? I do from mpl_toolkits.mplot3d import Axes3D ax = Axes3D(gcf()) x,y,z = randn(3,20) ax.scatter(x,y,z,s=30*rand(20)) and I expect to see 20 points of a range of sizes from 1 to 30... but instead I see them all the same size. How can I set the size of the markers? -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] vector EPS
Hi Matt, I cannot see any difference between matplotlib generated eps and others. I used the code below to generate the attached eps. Maybe you could be more specific in what is rasterized in the wrong way. By the way what version of matplotlib you are using? Kind regards, Matthias import matplotlib matplotlib.use(PS) # using PS-backend (non-interactive) import matplotlib.pyplot as plt import numpy as np x = np.linspace(0.0, 2*np.pi, 200) plt.plot(x, np.sin(x)) plt.savefig(my_test.eps) On Thursday 21 January 2010 07:50:07 Matthew Czesarski wrote: Hi Forum, I just had an article accepted and they want to have the figures in vector EPS format with text that can be re-sized. I have produced all my figures with matplotlib. However, it seems that MPL rasterizes everything in the production of its EPS output. Is there any way to get around this without learning a new plotting package? Cheers, Matt attachment: my_test.eps-- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] mplot3d scatter3d marker sizes?
Hi Erik, with current svn I see markers of different size. What version of matplotlib you are using? Kind regards, Matthias On Monday 18 January 2010 21:38:25 Erik Tollerud wrote: Is there a way to change the sizes of scatter plot markers for mplot3d.Axes3D.scatter3d ? I do from mpl_toolkits.mplot3d import Axes3D ax = Axes3D(gcf()) x,y,z = randn(3,20) ax.scatter(x,y,z,s=30*rand(20)) and I expect to see 20 points of a range of sizes from 1 to 30... but instead I see them all the same size. How can I set the size of the markers? -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Adding points gradually to the plot
Hello, I think you could do the following On Wednesday 13 January 2010 19:14:08 Someday... wrote: Hello all, I am looking for a way to add points gradually to the plot over time. Currently, in every iteration, I plot the entire array, like: plt.ion() # turn on interactive mode (otherwise the window arises not before show()) fig = plt.figure(); ax = fig.gca() xs = array([]) ys = array([]) # plot empty line to generate line object line, = ax.plot(xs,ys) while not done: // do some calculation.. // x=???, y=??? xs = append(xs,x); ys = append(ys,y); # reset line-data instead of new plotting line.set_data(xs, ys) plt.draw() plt.ioff() # turn off interactive mode In my experience this is better than plotting more and more versions of the same line or plotting one line for each '(x, y)'-data set ( I think this is due to the fact that each line-object holds information about its data, color, linetype, linewidth, marker, ...). Kind regards, Matthias However, it seems like that the figure is re-drawn completely and so significantly harms the performance. Rather, I want to add point each iteration to the plot. fig = plt.figure(); ax = fig.gca() while not done: // do some calculation.. // x=???, y=??? ax.AddPoint(x,y) plt.draw() // or update()? I searched tutorials, but I couldn't find anything related yet. If anyone knows how, please let me know. Thanks all, -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] xlim and xticks
Hi Pierre, I'm not sure I understand correctly - maybe you could provide a small stand-alone example which illustrates your problem. For me the following works fine: ax = axes() ax.bar(arange(10), np.random.uniform(size=10)) xticks(0.5+arange(10), [$a_%i$ % (i) for i in arange(10)]) xlim(xmax=12) show() Kind regards, Matthias On Thursday 14 January 2010 09:42:24 Pierre-Yves wrote: Dear all, I am facing a small problem with xlim and xticks and nor google nor the api helped me (one of the reason being that I likely don't know the exact term I am looking for). I am plotting a barplot using pyplot and bar() on matplotlib 0.98.5.2. If I do not use xticks the x axis goes from 0 to 500 leaving some empty space at the right of the last bar before the frame. When I use xticks to name my bar (name being either a string or nothing I tried both), then the frame come beside the last bar on the right of the plot. Then problem is that I want to keep this space between the last bar and the frame. I looked at pyplot.xlim(0,500) pyplot.xlim(xmax = 500) but if print pyplot.axis() returns the correct dimension the frame still persists at this place. How could I set the width correctly and use xticks ? I hope I am clear in my explanations. Pierre --- --- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] newbie question: type check?
Hi Nico, I'm sorry I cannot help you, but at least I'd like to share my findings with you: I find the following statements to be true: isinstance(gca(), matplotlib.axes.SubplotBase) isinstance(gca(), matplotlib.axes.Subplot) isinstance(gca(), matplotlib.axes.Axes) but there is no class 'AxesSubplot' in matplotlib.axes. I think this class is somehow dynamically generated from Axes and Subplot, but I have no idea how this works. Kind regards, Matthias On Tuesday 12 January 2010 11:40:21 Nico Schlömer wrote: Hm. print type( gca() ) print gca().__class__ print isinstance( gca(), matplotlib.axes.AxesSubplots) yields class 'matplotlib.axes.AxesSubplot' class 'matplotlib.axes.AxesSubplot' Traceback (most recent call last): File ./testfunctions.py, line 13, in module print isinstance( a, matplotlib.axes.AxesSubplots) AttributeError: 'module' object has no attribute 'AxesSubplots ?Nico On Tue, Jan 12, 2010 at 6:45 AM, Joshua J. Kugler jos...@eeinternet.com wrote: On Monday 11 January 2010, Nico Schlömer elucidated thus: quick question from a Python noob: Suppose I have an instance of an object of matplotlib, Is there any way to check on its type, e.g., whether it is an instance of matplotlib.axes.AxesSubplots? Python's built-in 'isintance.' isinstance(var, matplotlib.axes.AxesSubplots) j -- Joshua Kugler Part-Time System Admin/Programmer http://www.eeinternet.com PGP Key: http://pgp.mit.edu/ ID 0x14EA086E -- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Setting Relative Heights For Figure Rows
Hi Chris, I think pyplot.axes does what you are after, e.g. ax1 = axes([0.1, 0.3, 0.8, 0.6]) ax2 = axes([0.1, 0.1, 0.8, 0.1]) Kind regards, Matthias from the docs of pyplot.axes: `axes(rect, axisbg='w')`` where *rect* = [left, bottom, width, height] in normalized (0, 1) units. *axisbg* is the background color for the axis, default white. On Monday 11 January 2010 15:54:10 Chris Spencer wrote: I wanted to display my figure legend below my figure in the second row, so I used subplot(211) to create two rows. However, this creates two rows of equal height, so my graph is crammed into half the figure height in the first row, while my tiny legend barely fills up any of the second row. How do you specify relative heights of each row? For example, I'd like to specify the first row takes 80% of the figure height, while the second takes 20%. I've searched the docs, but I can't find anything. Is this possible? Regards, Chris --- --- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bar/hist plots, bottom on top or right axis
Hi Renato, I think you have to flip the x-axis of the left plot by for instance ax1 = subplot(121, xlim=(1, 0)) and I think than hist(data, orientation='horizontal') or manually using barh-plots works fine. Kind regards, Matthias On Thursday 07 January 2010 22:12:56 Renato Alves wrote: What I'm trying to accomplish is something like: http://bm2.genes.nig.ac.jp/RGM2/R_current/library/plotrix/man/images/big_py ramid.plot_001.png For that I was trying to use subplots where both draw in horizontal orientation but one will be flipped or mirrored. I couldn't find any parameter to do so. There is left for horizontal plots but no right. The same goes for bottom, but no top. Is there any way to achieve this? Thanks, Renato -- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] clabel( CS, manual=True ) / ginput_manual_clabel.py - broken?
Hi JJ, I'm sorry for the late response - I was on chrismas holidays and in fact even now I have not much time. I tested you patch and there arise labels - thanks a lot so far. Where should I post the bug report? on sourgeforge.net in the Bug Tracking System of matplotlib? Kind regards, Matthias On Saturday 19 December 2009 19:53:56 Jae-Joon Lee wrote: I can reproduce this bug with the current svn. Matthias, can you file a bug on this in the issue tracker? I think the bug is related with the changes made back in august. http://old.nabble.com/ginput-default-mouse-configuration-td24924861.html Attached is a quick fix, so please test it. I didn't thoroughly follow the changes made related with the above conversation, so I hope those involved (Jack Sankey, John and Gaël) take a look and make a relevant changes if necessary. Regards, -JJ On Tue, Dec 15, 2009 at 10:22 AM, Matthias Michler matthiasmich...@gmx.net wrote: Hello list, I run into trouble with the formelly working example ''ginput_manual_clabel.py'' or the following minimal example (in ipython -pylab) CS = plt.contour(reshape(arange(20)%3, (4, 5)), [0, 1, 2]) CL = plt.clabel( CS, manual=True ) First of all I get a DeprecationWarning during the startup (for GTKAGG and TKAGG) /scratch/michler/SOFT/lib/python2.5/site-packages/matplotlib/backend_base s.py:1793: DeprecationWarning: Using default event loop until function specific to this GUI is implemented warnings.warn(str,DeprecationWarning) and the worse point is that I am not able to select some clabel-positions (GTKAGG, TKAGG and WXAGG) and if I try to leave the selection mode I get GTKAGG: type 'exceptions.TypeError': stop_event_loop() takes exactly 1 argument (2 given) /scratch/michler/SOFT/lib/python2.5/site-packages/matplotlib/blocking_in put.py(196)mouse_event_stop() 195 # returned before using data. -- 196 self.fig.canvas.stop_event_loop(event) 197 TKAGG: File /usr/lib/python2.5/lib-tk/Tkinter.py, line 920, in update self.tk.call('update') _tkinter.TclError: can't invoke update command: application has been destroyed WXAGG: nothing Could anybody help me? Kind regards, Matthias - - Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] clabel( CS, manual=True ) / ginput_manual_clabel.py - broken?
Hi JJ, Bugs item #2922835, was opened at 2009-12-29 15:29 Happy New Year! Kind regards, Matthias On Tuesday 29 December 2009 15:13:39 Matthias Michler wrote: Hi JJ, I'm sorry for the late response - I was on chrismas holidays and in fact even now I have not much time. I tested you patch and there arise labels - thanks a lot so far. Where should I post the bug report? on sourgeforge.net in the Bug Tracking System of matplotlib? Kind regards, Matthias On Saturday 19 December 2009 19:53:56 Jae-Joon Lee wrote: I can reproduce this bug with the current svn. Matthias, can you file a bug on this in the issue tracker? I think the bug is related with the changes made back in august. http://old.nabble.com/ginput-default-mouse-configuration-td24924861.html Attached is a quick fix, so please test it. I didn't thoroughly follow the changes made related with the above conversation, so I hope those involved (Jack Sankey, John and Gaël) take a look and make a relevant changes if necessary. Regards, -JJ On Tue, Dec 15, 2009 at 10:22 AM, Matthias Michler matthiasmich...@gmx.net wrote: Hello list, I run into trouble with the formelly working example ''ginput_manual_clabel.py'' or the following minimal example (in ipython -pylab) CS = plt.contour(reshape(arange(20)%3, (4, 5)), [0, 1, 2]) CL = plt.clabel( CS, manual=True ) First of all I get a DeprecationWarning during the startup (for GTKAGG and TKAGG) /scratch/michler/SOFT/lib/python2.5/site-packages/matplotlib/backend_ba se s.py:1793: DeprecationWarning: Using default event loop until function specific to this GUI is implemented warnings.warn(str,DeprecationWarning) and the worse point is that I am not able to select some clabel-positions (GTKAGG, TKAGG and WXAGG) and if I try to leave the selection mode I get GTKAGG: type 'exceptions.TypeError': stop_event_loop() takes exactly 1 argument (2 given) /scratch/michler/SOFT/lib/python2.5/site-packages/matplotlib/blocking_ in put.py(196)mouse_event_stop() 195 # returned before using data. -- 196 self.fig.canvas.stop_event_loop(event) 197 TKAGG: File /usr/lib/python2.5/lib-tk/Tkinter.py, line 920, in update self.tk.call('update') _tkinter.TclError: can't invoke update command: application has been destroyed WXAGG: nothing Could anybody help me? Kind regards, Matthias -- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] mplot3d: plot_surface() and contour on grid?
Hi Reinier, that looks great! Thanks a lot for all your effort! Kind regards, Matthias On Friday 11 December 2009 00:36:59 Reinier Heeres wrote: Hi, I just committed a patch to do this in svn, also allowing for contour lines along other directions. See the attached image for an example. Cheers, Reinier On Thu, Dec 3, 2009 at 10:01 AM, Matthias Michler matthiasmich...@gmx.net wrote: Thanks a lot! Regards, Matthias On Wednesday 02 December 2009 17:10:54 Reinier Heeres wrote: Hi Matthias, I have a similar patch lying around somewhere, and I will try to apply it soon. I've been terribly busy lately, but I expect some nice mplot3d enhancements in the very near future. Regards, Reinier On Wed, Dec 2, 2009 at 4:22 PM, Matthias Michler matthiasmich...@gmx.net wrote: Hi Andrew, do you have any idea if the patch (or a part of it) may get a part of matplotlib-svn some day? Kind regards, Matthias On Friday 09 October 2009 23:25:28 Andrew Straw wrote: Matthias Michler wrote: Hello list, I'm not an expert in axes3d, but in case the feature which Nicolas requested is not possible in an easy manner up to now, I propose an additional kwarg for axes3d.Axes3D.contour. Something like *offset*. If offset is None the z-values of the contour lines corresponds to given Z and otherwise offset is used for the z-values of the contour lines. I attached a changed axes3d.py and a patch against current svn. The result is illustrated in the contour3d_demo.png. Could any of the experts have a look at it and tell me if this could be useful, please? Thanks in advance for any comments. Kind regards Matthias On Wednesday 30 September 2009 19:22:42 Nicolas Bigaouette wrote: Hi, I have a nice plot_surface() using mplot3d (see attachement). I'd like to project the surface on the axis xoy, xoz and yoz with a contour, similar to this figure: http://homepages.ulb.ac.be/~dgonze/INFO/matlab/fig19.jpg Is it possible using matplotlib and mplot3d? Thanx! Hi Matthias, I committed your patch to a github branch of MPL, but I'll let Reinier actually commit something based on this to MPL. http://github.com/astraw/matplotlib/tree/dev/michler-3d-contourf-offs ets -Andrew - - Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [matplotlib] can't get any output
Hi Manuel, adding a show() to your script should resolve the problem. You don't need this using ipython in -pylab mode, matplotlibs interactive mode or if you save your figure to some file (savefig), but in your case you need to call the main loop. Kind regards Matthias from the docu: Use show() The user interface backends need to start the GUI mainloop, and this is what show() does. It tells matplotlib to raise all of the figure windows and start the mainloop. Because the mainloop is blocking, you should only call this once per script, at the end. If you are using matplotlib to generate images only and do not want a user interface window, you do not need to call show. On Friday 11 December 2009 10:39:40 Manuel Wittchen wrote: Hi, I want to plot data from two different datafiles. To do so I use numpy.loadtxt two times in the script (see below). The problem is, that I don't get any output: no resulting plot, no errormessages or something in the terminal. Even if I comment-out one loadtxt-row nothing happens. Even if I try to plot something simple without using the loaded datafiles, nothing happens. Other files with simple plots without using a datafile work fine. Can't find my mistake. Manuel #!/usr/bin/env python from pylab import * import numpy as np datafile1 = '/path/to/datafile1.dat' datafile2 = '/path/to/datafile2.dat' TIME_F, STIRRER, O2, CO2 = np.loadtxt(datafile1, dtype='float', comments='#', delimiter='\t', usecols=(0,1,2,3), unpack=True) TIME_H, OD, FLUOR, BTM, GLY = np.loadtxt(datafile2, dtype='float', comments='#', delimiter='\t', usecols=(0,1,2,3,4), unpack=True) plot(TIME_F, O2) -- Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] positions of the ticks and ticklabels
Hi Abhi, I added an example program which illustrates my idea using transformation of axes-coord. to screen-coord. and from screen-coord. to fig-coord. point_screen = ax.transAxes.transform_point(point_ax) point_fig = fig.transFigure.inverted().transform_point(point_screen) I don't know if this is the best approach, but (at least) this works for me. Kind regards, Matthias On Monday 07 December 2009 21:38:17 Abhimanyu Lad wrote: Hi, How do I get the coordinates of the ticks and their labels in a coordinate system that I can feed to figtext or text? I want to display some additional text near one of the ticklabels on the x axis. Although I could get the coordinates for figtext using trial and error, but is there a correct way of doing this (using transformations?) so that my text does not move relative to the tick labels. Thanks! Abhi positions_of_the_ticks_and_ticklabels.py Description: application/python -- Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] textbox / prompt in mpl / inputbutton
Hello list, are there any new developments about a field to input text or numbers, which was discussed in thread Prompt in MPL - NEVER MIND in June 2007? Especially I am interested if there exists a version of John Hunters textbox2.py working with current svn, because I am not able to resolve the differences between 0.91.2 and 1.0.svn. Kind regards, Matthias -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Customize/disable keyboard shortcuts
Hi Jorge, Hello list, unfortunately I cannot help you, but I understand your problem and would like to know about a solution, too. I encountered this problem in April/may 2007 (http://old.nabble.com/skip-mpl-axes-interaction-during-key_press_event's-td10221576.html) because of the 'l'ogarthmic scaling, 'g'ridding etc., but in the meanwhile the number of keyboard-shortcuts has even increased. Therefore in my opinion it is important to support disabling of these keyboard-shortcuts, because otherwise there is not much space left for individual (meaningful) shortcuts. Furthermore I think this can also useful for buttons and sliders from matplotlib.widgets, because one don't want to scale or set grid upon these widgets, isn't it? What do other users think about that? Thanks in advance for any comments or even solutions. Kind regards, Matthias On Sunday 29 November 2009 12:10:09 Jorge Scandaliaris wrote: Hi, I have a strong preference to working with the keyboard instead of the mouse. Today I was working on a script to label a sequence of images (mark position and scale of a moving object). The default keyboard shortcuts are getting in my way, many keys are already used and moreover they are spread all over the keyboard. Looking at the doc, I could't find an easy way to customize or completely disable them. If someone can suggest a (not too coonvoluted) solution, I'd love to hear it. Cheers, Jorge -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] mplot3d: plot_surface() and contour on grid?
Thanks a lot! Regards, Matthias On Wednesday 02 December 2009 17:10:54 Reinier Heeres wrote: Hi Matthias, I have a similar patch lying around somewhere, and I will try to apply it soon. I've been terribly busy lately, but I expect some nice mplot3d enhancements in the very near future. Regards, Reinier On Wed, Dec 2, 2009 at 4:22 PM, Matthias Michler matthiasmich...@gmx.net wrote: Hi Andrew, do you have any idea if the patch (or a part of it) may get a part of matplotlib-svn some day? Kind regards, Matthias On Friday 09 October 2009 23:25:28 Andrew Straw wrote: Matthias Michler wrote: Hello list, I'm not an expert in axes3d, but in case the feature which Nicolas requested is not possible in an easy manner up to now, I propose an additional kwarg for axes3d.Axes3D.contour. Something like *offset*. If offset is None the z-values of the contour lines corresponds to given Z and otherwise offset is used for the z-values of the contour lines. I attached a changed axes3d.py and a patch against current svn. The result is illustrated in the contour3d_demo.png. Could any of the experts have a look at it and tell me if this could be useful, please? Thanks in advance for any comments. Kind regards Matthias On Wednesday 30 September 2009 19:22:42 Nicolas Bigaouette wrote: Hi, I have a nice plot_surface() using mplot3d (see attachement). I'd like to project the surface on the axis xoy, xoz and yoz with a contour, similar to this figure: http://homepages.ulb.ac.be/~dgonze/INFO/matlab/fig19.jpg Is it possible using matplotlib and mplot3d? Thanx! Hi Matthias, I committed your patch to a github branch of MPL, but I'll let Reinier actually commit something based on this to MPL. http://github.com/astraw/matplotlib/tree/dev/michler-3d-contourf-offsets -Andrew -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] usetex=True and savefig(eps-file)
Hi Jouni, Thanks for your explaination. On Wednesday 02 December 2009 17:20:37 Jouni K. Seppänen wrote: Matthias Michler matthiasmich...@gmx.net writes: ./root/article.cls.tex: Permission denied ./root/article.cls: Permission denied ./lost+found/article.cls.tex: Permission denied ./lost+found/article.cls: Permission denied ./root/article.cls.tex: Permission denied ./root/article.cls: Permission denied ./lost+found/article.cls.tex: Permission denied ./lost+found/article.cls: Permission denied That looks like a TeX configuration problem. I'm guessing that when TeX encounters \documentclass{article}, it asks the path-searching library for article.cls, and for some reason /root and /lost+found are included in the path. You don't have permission as normal user to access these directories, so the library causes error messages to be printed. The path probably also includes the correct directories, so the search eventually succeeds, but then article.cls wants to input size10.clo, causing a new round of errors: ./root/size10.clo.tex: Permission denied ./root/size10.clo: Permission denied (etc) Do you know why is happens only for ps/eps-files? Have you set any TeX-related environment variables or edited any configuration files? What does kpsepath tex print? in my .zshrc I set TEXINPUTS=~/Texte/Styles//:.//: export TEXINPUTS and $ kpsepath tex yields /home/michler/Texte/Styles//:.//:.:/home/michler/.texmf-config/tex/kpsewhich//:/home/michler/.texmf-var/tex/kpsewhich//:/home/michler/texmf/tex/kpsewhich//:/etc/texmf/tex/kpsewhich//:!!/var/lib/texmf/tex/kpsewhich//:!!/usr/local/share/texmf/tex/kpsewhich//:!!/usr/share/texmf/tex/kpsewhich//:!!/usr/share/texmf-texlive/tex/kpsewhich//:/home/michler/.texmf-config/tex/generic//:/home/michler/.texmf-var/tex/generic//:/home/michler/texmf/tex/generic//:/etc/texmf/tex/generic//:!!/var/lib/texmf/tex/generic//:!!/usr/local/share/texmf/tex/generic//:!!/usr/share/texmf/tex/generic//:!!/usr/share/texmf-texlive/tex/generic//:/home/michler/.texmf-config/tex///:/home/michler/.texmf-var/tex///:/home/michler/texmf/tex///:/etc/texmf/tex///:!!/var/lib/texmf/tex///:!!/usr/local/share/texmf/tex///:!!/usr/share/texmf/tex///:!!/usr/share/texmf-texlive/tex/// Furthermore I did (as root): $ cd /root$ cd /lost+found/ and $ cd /tmp/ and $ ls **/*tex **/*.cls but always got ls: cannot access **/*tex: No such file or directory ls: cannot access **/*.cls: No such file or directory ... That means there are no tex or cls-files. Do you have any idea what's wrong? Kind regards, Matthias -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] usetex=True and savefig(eps-file)
Hi Jouni, thanks again for your advice. I don't think that I do have 'some setting that causes temporary files to end up in the root directory, because my system is more or less kubuntu (8.04) out of the box. But maybe you are nevertheless right, because in tmp there are ./root and ./lost+found, which I am not allowed to enter. Finally this error is due to the behaviour of ps-backend and my TEX-path, which searches in all sub-directories. Thanks a lot for your time and advice to locate the root of the strange behaviour. Kind regards, Matthias On Thursday 03 December 2009 19:04:55 Jouni K. Seppänen wrote: Matthias Michler matthiasmich...@gmx.net writes: Do you know why is happens only for ps/eps-files? The ps backend uses TeX in a different way than the other backends. It uses psfrag and dvips to construct the final file. Have you set any TeX-related environment variables or edited any configuration files? What does kpsepath tex print? in my .zshrc I set TEXINPUTS=~/Texte/Styles//:.//: It's probably the .// entry, which causes TeX to search all subdirectories of the current directory. The ps backend does something like cd /tmp latex file.tex so it should just look in subdirectories of the temporary directory, but perhaps it somehow goes awry. Do you have some setting that causes temporary files to end up in the root directory? -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to display axis numbers inside the figure area
Hi Angelica, I have to admit I don't get the point of what you want to do and maybe this is true for others too. I tried something (see attachement), but maybe it is better if you could set up an small example script or draw a picture of what you want to see finally. Kind regards, Matthias On Monday 30 November 2009 18:09:29 Pekeika wrote: Good morning All, I am creating figures that need to overlay with maps, so disabling the box around my figures is a must. (need no title, legend, etc...) I have my plain figure now without surroundings but now need the axis numbers on the grid inside the plot area (like latitude and longitude numbers appear next to the grids on maps)... I cannot find a function or an argument for the axis() or axes() functions that translates axes into the plot area... Any ideas please? Thank you so much, Angelica. attachment: axes_numbers.png axes_numbers.py Description: application/python -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Computing Simple Statistics from a Histogram
Hi Wayne, you are right all these function use the sample-data and not the pdf / frequency of occurence-histogram, because typically the data is available and not the pdf. Maybe the scipy mailing list could give you a solution to your problem. In case that your freqency of occurence are integers you could do something like the following to generate the sample-data and than you the previous mentioned functions: bin_centers = np.array([ 1., 2., 3., 4., 5.]) n_vals = np.array([1, 3, 0, 2, 1]) sample_new = np.array([]) for bin_center, n in zip(bin_centers, n_vals): # append new value 'n' times: sample_new = np.concatenate((sample_new, [bin_center]*n)) Kind regards, Matthias On Tuesday 01 December 2009 17:51:31 Wayne Watson wrote: I do not believe that any of those calculations are based on the pdf, frequency of occurrence-histogram. This, (1, 2,2, 4, 2,5,4) and not this (1,3, 0,2,1). The latter are the frequencies of occurrence for 1,2,3,4,5. John Hunter wrote: On Tue, Dec 1, 2009 at 6:32 AM, Wayne Watson sierra_mtnv...@sbcglobal.net wrote: Is there some statistics function that computes the mean, std. dev., min/max, etc. from a frequency distribution? numpy has many functions for basic descriptive statistics. If data is an array of your data, you can do (import numpy as np) mean: np.mean(data) median: np.median(data) standard deviation: np.std(data) min: np.min(data) max: np.max(data) In scipy.stats, there are many more (skew, kurtosis, etc...) See also, this example: http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/py4science/ examples/stats_descriptives.py?view=markuppathrev=4027 JDH -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Engineering prefixed units in tick labels
Hi Jason, Hi list, First of all let me say I like the EngFormatter of Jason. Are there plans to incorparate it into matplotlib? I cannot find any indication for this in current svn, but I would like to see the EngFormatter in matplotlib. Therefore I tried to include Jasons proposal into the ticker.py as a new class EngFormatter including the method 'self.format_eng'. I made some changes, which might break some of Jasons ideas, but I cannot see (1) why we need the LogFormatter as base class instead of Formatter? (2) why one should decide for only decade-labels. Therefore I removed the corresponding if-statement. It causes errors () if you use an axes including '0', which could be useful for eng-formatting, too. (3) Could we always use format_str = %g %s instead of specifying 'places'? Because of successive zomming I don't want to specify 'places' before calling 'plt.show'. Therefore I introduced places =None to use %g %s. I attached the new ticker.py and a diff against current svn (I'm sorry I couldn't resist to add some white spaces). Any comments are welcome. Kind regards, Matthias Michler On Wednesday 25 November 2009 01:39:43 Jason Heeris wrote: Hi, 2009/11/18 Jason Heeris jason.hee...@gmail.com: In gnuplot, I can do the following: set format x %.0s %cHz ...and this will set the x-axis labels (on a semilogx style plot) to be 10 Hz, 100 Hz, 1 kHz, 10 kHz, etc. I ended up implementing this myself, it wasn't too hard. I've attached the code if anyone else is interested. I don't know matplotlib that well, so I don't know if there's much duplication of code in there. I thought I'd CC the dev list in case others think it might be useful. If not, sorry for the noise. Cheers, Jason Index: ticker.py === --- ticker.py (revision 8000) +++ ticker.py (working copy) @@ -118,6 +118,7 @@ from __future__ import division +import decimal import math import numpy as np from matplotlib import rcParams @@ -507,23 +508,23 @@ is ``False`` self._base = base+0.0 -self.labelOnlyBase=labelOnlyBase +self.labelOnlyBase = labelOnlyBase self.decadeOnly = True -def base(self,base): +def base(self, base): 'change the *base* for labeling - warning: should always match the base used for :class:`LogLocator`' -self._base=base +self._base = base -def label_minor(self,labelOnlyBase): +def label_minor(self, labelOnlyBase): 'switch on/off minor ticks labeling' -self.labelOnlyBase=labelOnlyBase +self.labelOnlyBase = labelOnlyBase def __call__(self, x, pos=None): 'Return the format for tick val *x* at position *pos*' vmin, vmax = self.axis.get_view_interval() d = abs(vmax - vmin) -b=self._base +b = self._base if x == 0.0: return '0' sign = np.sign(x) @@ -533,13 +534,13 @@ if not isDecade and self.labelOnlyBase: s = '' elif x1: s= '%1.0e'%x elif x1: s = '%1.0e'%x -else: s = self.pprint_val(x,d) +else: s = self.pprint_val(x, d) if sign == -1: s = '-%s' % s return self.fix_minus(s) -def format_data(self,value): +def format_data(self, value): self.labelOnlyBase = False value = cbook.strip_math(self.__call__(value)) self.labelOnlyBase = True @@ -554,14 +555,14 @@ return abs(x-n)1e-10 def nearest_long(self, x): -if x==0: return 0L -elif x0: return long(x+0.5) +if x == 0: return 0L +elif x 0: return long(x+0.5) else: return long(x-0.5) def pprint_val(self, x, d): #if the number is not too big and it's an int, format it as an #int -if abs(x)1e4 and x==int(x): return '%d' % x +if abs(x) 1e4 and x == int(x): return '%d' % x if d 1e-2: fmt = '%1.3e' elif d 1e-1: fmt = '%1.3f' @@ -572,7 +573,7 @@ s = fmt % x #print d, x, fmt, s tup = s.split('e') -if len(tup)==2: +if len(tup) == 2: mantissa = tup[0].rstrip('0').rstrip('.') sign = tup[1][0].replace('+', '') exponent = tup[1][1:].lstrip('0') @@ -645,11 +646,106 @@ if usetex: s = r'$%s%d^{%d}$'% (sign_string, b, self.nearest_long(fx)) else: -s = r'$\mathdefault{%s%d^{%d}}$'% (sign_string, b, self.nearest_long(fx)) +s = r'$\mathdefault{%s%d^{%d}}$'% (sign_string, b, + self.nearest_long(fx)) return s +class EngFormatter(Formatter): + +Formats axis values using engineering prefixes to represent powers of 1000, +plus a specified unit, eg. 10 MHz instead of 1e7. +example: +from matplotlib.ticker import
Re: [Matplotlib-users] Engineering prefixed units in tick labels
Hi John, Hello list, I added the patch to the tracker (ID 2907509). Kind regards Matthias On Wednesday 02 December 2009 13:40:29 John Hunter wrote: On Wed, Dec 2, 2009 at 4:02 AM, Matthias Michler matthiasmich...@gmx.net wrote: Hi Jason, Hi list, First of all let me say I like the EngFormatter of Jason. Are there plans to incorparate it into matplotlib? I cannot find any indication for this in current svn, but I would like to see the EngFormatter in matplotlib. Therefore I tried to include Jasons proposal into the ticker.py as a new class EngFormatter including the method 'self.format_eng'. I am interested in this -i I just missed Jason's original email last week so thanks for bringing it back to our attention. Please post this as a patch on the tracker http://sourceforge.net/tracker2/?group_id=80706 since I don't have time to review it right now and I don't want it to fall through the cracks. JDH -- Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users