[Matplotlib-users] contour plot for newbie
Hi to all, I'm trying to make a contour plot from the beginning, I mean from a 3 column data file X,Y,Z, but I don't know how to do it without, e.g., origin and I want to use and to learn better matplotlib. what's the first thing to do? I imagine something like gridding data, but I've done a lot of attempts obtaining just a lot of error output. which is the way to grid with matplolib? after the grid, I have to use the contour(Z). In each case I've tried, also with the example of the matplotlib, It complains about some missing libraries of numpy (numpy.ma): I tried to install from scratch... I surfed the net, I found something but I'm a newbie both in matplolib and in python, so I'd be very happy if someone of you could help me from the beginning. Thanks a lot in advance Francesco p.s. my O.S. cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=8.04 DISTRIB_CODENAME=hardy DISTRIB_DESCRIPTION=Ubuntu 8.04.3 LTS python -V Python 2.5.2 -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to customize informations given by the navigation toolbar ?
It would be very fine to me, but unfortunately, I have to use matplotlib 0.91.2. Is there a way to adapt this to the old transform API ? Thanks -- LB -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Problem with hist
Hi, I need to know why the attached code works in one case and takes forever to run in the other one. I don't think I've done anything wrong and I tried everything that came to my mind now. If you use x1 = mu + sigma * np.random.randn(1000) instead of x1 = np.array([np.float64(val / 2.0) for val in x0], np.float64) Why doesn't this work if its the same array divided by 2 ? Thanks, Axel Gembe #!/usr/bin/env python # -*- coding: utf-8 -*- import sys, codecs #import matplotlib #matplotlib.use('Agg') import numpy as np import matplotlib.pyplot as plt mu, sigma = 75, 25 x0 = mu + sigma * np.random.randn(3000) # First one works, second one doesn't, why? #x1 = mu + sigma * np.random.randn(1000) x1 = np.array([np.float64(val / 2.0) for val in x0], np.float64) print '%r' % x0 print '%s' % type(x0).__name__ print '%r' % x1 print '%s' % type(x1).__name__ n, bins, patches = plt.hist((x0, x1), bins = 25, normed = False, histtype = 'bar') sys.stdout.flush() sys.stdout = codecs.open(test.png, wb, None) plt.savefig(sys.stdout, filetype='png') -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to customize informations given by the navigation toolbar ?
Seems that the following lines did the trick with matplotlib 0.91.2 xy_pixel = self.a3.transData.xy_tup((x3,y3)) x1, y1 = self.a1.transData.inverse_xy_tup(xy_pixel) Thanks 2009/10/16 LB bravo.l...@gmail.com It would be very fine to me, but unfortunately, I have to use matplotlib 0.91.2. Is there a way to adapt this to the old transform API ? Thanks -- LB -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Problem with hist
Axel Gembe wrote: Hi, I need to know why the attached code works in one case and takes forever to run in the other one. I don't think I've done anything wrong and I tried everything that came to my mind now. If you use x1 = mu + sigma * np.random.randn(1000) instead of x1 = np.array([np.float64(val / 2.0) for val in x0], np.float64) Why doesn't this work if its the same array divided by 2 ? Thanks, Axel Gembe OK, actually I didn't construct x1 from x1 but from x0 in the code. The problem only happens when both arrays have the same length, content does not matter. Axel Gembe -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] all fonts to sans-serif?
On Thu, Oct 15, 2009 at 10:38 AM, Christian Meesters meest...@imbie.uni-bonn.de wrote: Hi, I'd like to have all sub-fonts (labels, tick labels, text) sans-serif for a series of plots per default. However the appropriate settings in .matplotlibrc apparently don't work and this also does not work: import matplotlib as mpl mpl.rcParams['text.usetex'] = True mpl.rcParams['font.family'] = 'sans-serif' mpl.rcParams['font.sans-serif'] = 'Bitstream Vera Sans' usetex uses latex's math mode for rendering ticklabels, and mathmode is rendered in serif. We tried supporting sans-serif once, and it turned out to be too complicated to cover all the corner cases. I think there may be a latex package that can be loaded for sans-serif math mode, but I don't remember what it is called. You could add that package invocation to your text.latex.preamble, but please note that text.latex.preamble is not officially supported (because it is so flexible, we don't want to troubleshoot latex issues on this list.) Darren -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Is there an easy way to turn on automatic subticks?
I am making regular Cartesian coordinate graphs with linear scales on the axis. I would really like to have automatic subticks to make reading data easier. Is there an easy way to do this? Thanks -mike w. -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Is there an easy way to turn on automatic subticks?
On Fri, Oct 16, 2009 at 12:23 PM, Michael Waters mjwat...@umich.edu wrote: I am making regular Cartesian coordinate graphs with linear scales on the axis. I would really like to have automatic subticks to make reading data easier. Is there an easy way to do this? Yes, you just need to set a locator for the minor ticks, which is set to NullLocator by default. import matplotlib.pyplot as plt from matplotlib.ticker import MaxNLocator plt.plot([1,2,3]) ax = plt.gca() ax.xaxis.set_minor_locator(MaxNLocator(nbins=30, steps=[1, 2, 5, 10])) plt.show() You might also want to look at: http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo1.html?highlight=codex%20minor Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Little issue with blitting technique
Bug reported: https://sourceforge.net/tracker/index.php?func=detailaid=2880692group_id=80706atid=560720 Does anybody where I could dig a little to try to correct it? It a really needed feature for me, so if I could help... Cheers, Laurent -Message d'origine- De : Jae-Joon Lee [mailto:lee.j.j...@gmail.com] Envoyé : jeudi 15 octobre 2009 05:23 À : Laurent Dufrechou Cc : matplotlib-users@lists.sourceforge.net Objet : Re: [Matplotlib-users] Little issue with blitting technique On Tue, Oct 13, 2009 at 1:02 PM, Laurent Dufrechou ldufrec...@marport.com wrote: Hello, I've tested so far with wx and QT4 backend. The two are buggy. Easy way to reproduce the bug (another way I mean) ax = p.subplot(212) ax2 = p.subplot(211) On mac with wxgtk, it works fine. Maybe this is an windows only issue. and the two backends got the same error. Since nobody steped in, and I don't use windows, can you file a bug report. http://sourceforge.net/tracker/?atid=560720group_id=80706func=browse Please provide a short, complete example that reproduces the bug. Also the error message you get. -JJ Note that I'm under windows. I'll try under linux tonight just to check. I'll also try gtk backend as you suggest. Update in next email :) -Message d'origine- De : Jae-Joon Lee [mailto:lee.j.j...@gmail.com] Envoyé : mardi 13 octobre 2009 18:36 À : Laurent Dufrechou Cc : matplotlib-users@lists.sourceforge.net Objet : Re: [Matplotlib-users] Little issue with blitting technique I haven't tested it with qt4, but with gtk, add_axes DOES work. So, can you try other backends and see if they work? And, I believe that add_subplot - add_axes is a only change you made? Unless the problem is persistent among other backends, I hope other developers who use qt4 backend step in and help. Regards, -JJ On Thu, Oct 8, 2009 at 11:30 AM, Laurent Dufrechou ldufrec...@marport.com wrote: Hello, I’ve just discovered blitting technique to improve performances. I’m using this example http://matplotlib.sourceforge.net/examples/animation/animation_blit_qt4 .html I encounter an issue if instead of using subplot I use add_axes method to hand define where I want my plot. In this case blitting is no more working like if restore_region was not restoring context… def __init__(self): FigureCanvas.__init__(self, Figure()) #self.ax = self.figure.add_subplot(111) self.ax = self.figure.add_axes([0.1,0.1,0.8,0.2]) Any idea why in this case the example given is not working? Cheers, Laurent -- --- - Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [matplotlib-devel] AutoDateFormatter/AutoDateLocator
On Oct 16, 2009, at 2:59 PM, Ryan May wrote: On Wed, Oct 14, 2009 at 3:59 PM, John Hunter jdh2...@gmail.com wrote: I don't have a strong opinion on this -- making it more customizable is a good thing -- this came up at scipy as well, where I contributed a patch to make the AutoDateFormatter a little more customizable by exposing a scaled dictionary mapping the scale to a format string. As long as the extension to the AutoDateLocator preserves the core functionality, I say have at it. Here's a patch that implements the ideas I have. To the best of my ability, it preserves the same behavior as before, it just opens it up to configuration by the user instead of being hard-coded. It adds: 1) Configuring the minimum number of ticks, which determines whether to do yearly, monthly, etc. ticking 2) Configuring the maximum number of ticks, which is used to select what interval of ticking to use. This is actually done on a per-frequency basis. This helps to keep in line with previous behavior and is useful for keeping tick spacing in line with what the label would be for a given frequency. The user can also simply pass an integer that gives the maximum for all frequencies. 3) A dictionary of intervals corresponding to each frequency. This keeps the previous functionality of appropriate intervals for each frequency, but also opens it up to user configuration. 4) Optional ticking on multiples of the interval. Previously, if you were ticking with, say, 10 minute intervals, and the range happened to start at 33 minutes, you'd get ticks at 33, 43, 53, etc. With this flag set, the ticks instead end up at 40, 50, 0, 10, etc. I'd appreciate anyone looking this over for any glaring problems before I check this in. I've done my best to preserve old functionality, though I'm still working on getting the unit tests to run here. It also passes my own testing here when I fiddle with the new knobs that have been exposed. My one question is: how important is keeping API compatibility? The constructor tries to follow the convention of the rest of the module (tz is last or nearly so), but this breaks compatibility (where tz was the only argument). Also, to me, it would be nice to tick multiples of the interval by default. Thoughts? Have you checked scikits.timeseries.lib.plotlib ? We provide some functions that adapt the ticks to the frequency of you base series, but also according to the range of the axes. For example, if you work with a 100-y daily timeseries, you'll have major ticks every 5 years if you plot the whole series, every month if you plot or zoom on one year only, etc. it may be worthwhile to give it a try. I'd be happy to help adapting our code to remove the dependency on scikits.timeseries if needed... -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] TR: Cleaver way to do a scrolling imshow?
Hello, I'm investigating a way to make a sort of imshow that is scrolling from right to left. My idea is to copy in a blit buffer from (1,0) to (xmax,ymax). Blit it @(0,0) (xmax-1,ymax) And then draw a cmap'ed line @x=xmax. So here are my question: How to draw a line that use a cmap=jet (for example)? I've taken a look at Line2D but it has no cmap argument. The only thing I've found is drawing a line with only one color. Any idea appreciated! Cheers, Laurent -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Cleaver way to do a scrolling imshow?
Hello, I'm investigating a way to make a sort of imshow that is scrolling from right to left. My idea is to copy in a blit buffer from (1,0) to (xmax,ymax). Blit it @(0,0) (xmax-1,ymax) And then draw a cmap'ed line @x=xmax. So here are my question: How to draw a line that use a cmap=jet (for example)? I've taken a look at Line2D but it has no cmap argument. The only thing I've found is drawing a line with only one color... Any idea appreciated! Cheers, Laurent -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plotting normalized histograms
hi all, i have a matrix of data and i would like to make a set of subplots, each subplot with a histgram of one of the columns of the data. the dataset is an Nx4 matrix containing only numbers between 0 and 1. i plot it like this: plt.subplot(2, 2, 1) # histogram of first column plt.hist(mydata[:, 0], 15) plt.subplot(2, 2, 1) # histogram of second column plt.hist(mydata[:, 1], 15) # etc... since i want the subplots to be comparable, i'd like hist to use the same bins for all subplots. how can i do this? also, i would like to, instead of showing counts on the y-axis, show the normalized probability of each bin. i looked into the normed optional argument, but i don't think it achieves this. my attempt to do this was: plt.hist(mydata[:, 0], 15, normed=1) but the y-axis is not set to be between 0 and 1. any ideas on how to do this would be greatly appreciated. thanks. plt.hist(mydata[:, 0] -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Is there an easy way to turn on automatic subticks?
Ryan May wrote: On Fri, Oct 16, 2009 at 12:23 PM, Michael Waters mjwat...@umich.edu wrote: I am making regular Cartesian coordinate graphs with linear scales on the axis. I would really like to have automatic subticks to make reading data easier. Is there an easy way to do this? Yes, you just need to set a locator for the minor ticks, which is set to NullLocator by default. import matplotlib.pyplot as plt from matplotlib.ticker import MaxNLocator plt.plot([1,2,3]) ax = plt.gca() ax.xaxis.set_minor_locator(MaxNLocator(nbins=30, steps=[1, 2, 5, 10])) plt.show() You might also want to look at: http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo1.html?highlight=codex%20minor Ryan That does it! Thanks a bunch. -mike w. -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] _legmarker attribute error in in legend using vlines
When I try to make a legend after using the vlines command, I get a _legmarker error. my code: / plot(two_theta,y_value_list_1) vlines(two_theta,[0],y_value_list_2,linewidth = 2) legend(['1','2'])/ the error: /Exception in Tkinter callback Traceback (most recent call last): File /usr/lib/python2.6/lib-tk/Tkinter.py, line 1413, in __call__ return self.func(*args) File /usr/lib/python2.6/dist-packages/matplotlib/backends/backend_tkagg.py, line 212, in resize self.show() File /usr/lib/python2.6/dist-packages/matplotlib/backends/backend_tkagg.py, line 215, in draw FigureCanvasAgg.draw(self) File /usr/lib/python2.6/dist-packages/matplotlib/backends/backend_agg.py, line 279, in draw self.figure.draw(self.renderer) File /usr/lib/python2.6/dist-packages/matplotlib/figure.py, line 772, in draw for a in self.axes: a.draw(renderer) File /usr/lib/python2.6/dist-packages/matplotlib/axes.py, line 1601, in draw a.draw(renderer) File /usr/lib/python2.6/dist-packages/matplotlib/legend.py, line 316, in draw self._update_legend_box(renderer) File /usr/lib/python2.6/dist-packages/matplotlib/legend.py, line 626, in _update_legend_box legline_marker = legline._legmarker AttributeError: 'Line2D' object has no attribute '_legmarker' /This stopped working after I installed ubuntu 9.4 thanks, -mike w. -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] _legmarker attribute error in in legend using vlines
I guess this is a known bug and already fixed. Maybe ubuntu 9.4 sheeps with the older version though (the bug was fixed in this January, so, I'm not sure). http://www.nabble.com/unable-to-create-legend-for-vlines-graph-td21707558.html#a21707558 You may try to install the latest version. Or you may use the option 4 as a work around. http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist Regards, -JJ On Fri, Oct 16, 2009 at 9:34 PM, Michael Waters mjwat...@umich.edu wrote: When I try to make a legend after using the vlines command, I get a _legmarker error. my code: plot(two_theta,y_value_list_1) vlines(two_theta,[0],y_value_list_2,linewidth = 2) legend(['1','2']) the error: Exception in Tkinter callback Traceback (most recent call last): File /usr/lib/python2.6/lib-tk/Tkinter.py, line 1413, in __call__ return self.func(*args) File /usr/lib/python2.6/dist-packages/matplotlib/backends/backend_tkagg.py, line 212, in resize self.show() File /usr/lib/python2.6/dist-packages/matplotlib/backends/backend_tkagg.py, line 215, in draw FigureCanvasAgg.draw(self) File /usr/lib/python2.6/dist-packages/matplotlib/backends/backend_agg.py, line 279, in draw self.figure.draw(self.renderer) File /usr/lib/python2.6/dist-packages/matplotlib/figure.py, line 772, in draw for a in self.axes: a.draw(renderer) File /usr/lib/python2.6/dist-packages/matplotlib/axes.py, line 1601, in draw a.draw(renderer) File /usr/lib/python2.6/dist-packages/matplotlib/legend.py, line 316, in draw self._update_legend_box(renderer) File /usr/lib/python2.6/dist-packages/matplotlib/legend.py, line 626, in _update_legend_box legline_marker = legline._legmarker AttributeError: 'Line2D' object has no attribute '_legmarker' This stopped working after I installed ubuntu 9.4 thanks, -mike w. -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users