[Matplotlib-users] Bold Latex Tick-Labels
Hi, I am making plots for a publication using matplotlib which requires the use of heavy fonts. I am rendering text in the graph with Latex, which has a limited capability to make fonts more heavy. I partially solved the problem using the \boldmath Latex command for the axis-labels and text inside the plot (see attached figure). The only remaining text to be bolden are the tick labels. I can change their size via the xtick.labelsize rc parameter, but do not know how to make them heavier. Does anybody know what can be done to solve this? Any help would be appreciated Best, Daniel http://old.nabble.com/file/p28037900/m8.png -- View this message in context: http://old.nabble.com/Bold-Latex-Tick-Labels-tp28037900p28037900.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- 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] Problems using bar() with left containing an array of float
Thanks Friedrich, I though the width was calculated on the fly. does it make sense to use something like plt.bar(bins, nb_per_bin, width=(max(bins)-min(bins)) / (1.5*len(bins))) If I want something more generic Tim Friedrich Romstedt wrote: You must give a proper :param width: argument: plt.bar(bins, height, 0.01) http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.bar Friedrich 2010/3/25 timothee cezard tcez...@staffmail.ed.ac.uk: Hi all, I'm trying to plot a distribution using bar() but when I'm setting the left variable to as a sequence of float some of the bar look weird. When I replace this sequence by a sequence of int it works fines Does anybody know why this happens and how I can fix it? Here is the code I'm using: if __name__==__main__: bins=[0.0, 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.60, 0.62, 0.64, 0.66, 0.68, 0.70, 0.72, 0.74, 0.76, 0.78, 0.80, 0.82, 0.84, 0.86, 0.88, 0.90, 0.92, 0.94, 0.96, 0.98, 1.0] height=[89775, 1665, 1791, 1695, 1467, 1395, 1306, 1169, 1252, 1134, 1190, 1117, 1018, 995, 1055, 904, 960, 886, 810, 821, 829, 763, 766, 857, 737, 862, 724, 852, 742, 644, 733, 679, 630, 672, 665, 659, 663, 653, 657, 700, 731, 721, 699, 871, 837, 913, 940, 966, 1028, 159774, 40002] fig = plt.figure() ax = fig.add_subplot(1,1,1) plt.bar(bins, height) plt.show() -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- 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
[Matplotlib-users] imshow is incorrect at the bottom axis
* The problem is universally seen on WinXP, WinVista and Ubuntu 9.10. * print matplotlib.__version__ = 0.99.1 * mpl was obtained from pythonxy on Windows and EPD on Linux * no customizations to matplotlibrc The attached example shows a square picture with equal settings for X and Y axes. While the X ticks coincide with the inter-square borders, the Y ticks are off (marked by circles). Now look closer to the border squares. These are by one screen pixel smaller in the direction to the corresponding axis (this pixel is transferred to the axis line), except for the bottom axis where the squares are by one pixel higher. This bug leads to a vertical shift in additional marks which I put over imshow images. Can you please make it more precise? Best regards, Konstantin import numpy as np import matplotlib.pyplot as plt x = np.random.normal(size=25) y = np.random.normal(size=25) nbins = 16 pixelPerBin = 16 dpi = 100 size2D = 0.8 origin2D = 0.1 figsize = nbins * pixelPerBin / (dpi * size2D) #inches fig = plt.figure(figsize=(figsize,figsize), dpi=dpi) fig.delaxes(fig.gca()) rect2D = [origin2D, origin2D, size2D, size2D] ax2DHist = fig.add_axes(rect2D, aspect='equal') range = [[-2, 2], [-2, 2]] hist2D, yedges, xedges = np.histogram2d(y, x, bins=[nbins, nbins], range=range, weights=x*y) extent = [-2, 2, 2, -2] ax2DHist.imshow(hist2D, aspect='equal', interpolation='nearest', origin='lower', extent=extent) plt.show()attachment: imshow_bug.png-- 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] Bold Latex Tick-Labels
On Fri, Mar 26, 2010 at 3:06 AM, konstellationen konstellatio...@gmail.comwrote: Hi, I am making plots for a publication using matplotlib which requires the use of heavy fonts. I am rendering text in the graph with Latex, which has a limited capability to make fonts more heavy. I partially solved the problem using the \boldmath Latex command for the axis-labels and text inside the plot (see attached figure). The only remaining text to be bolden are the tick labels. I can change their size via the xtick.labelsize rc parameter, but do not know how to make them heavier. Does anybody know what can be done to solve this? Any help would be appreciated Best, Daniel -- You can try: xticklabels = getp(gca(), 'xticklabels') yticklabels = getp(gca(), 'yticklabels') setp(xticklabels, fontsize=14, weight='bold') setp(yticklabels, fontsize=14, weight='bold') Those are nice looking plots. It would be nice them to be shared on mpl's gallery or as an example :) -- Gökhan -- 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] unconnected points
On Fri, Mar 26, 2010 at 3:23 AM, Ruben Moor ruben.m...@gmail.com wrote: Hello, I use the following plot command plot(tdata, vdata, '.-') with an unexpected result (s. attached png). Some points are not connected. If I plot with linestyle '-' you can't even see them. Is that a known issue ? What do I do wrong ? What is your matplotlib version? Could you share the data to test it? On the latest matplotlib source copy .- works nicely with a test plot like: plt.plot(np.random.random(100), .-) -- Gökhan -- 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] unconnected points
This may be the fault of the known bug in path simplification. If you set the rcParam path.simplify to False does that resolve it? (If that's the case, this bug should be fixed in the next release). Mike On 03/26/2010 11:12 AM, Gökhan Sever wrote: On Fri, Mar 26, 2010 at 3:23 AM, Ruben Moor ruben.m...@gmail.com mailto:ruben.m...@gmail.com wrote: Hello, I use the following plot command plot(tdata, vdata, '.-') with an unexpected result (s. attached png). Some points are not connected. If I plot with linestyle '-' you can't even see them. Is that a known issue ? What do I do wrong ? What is your matplotlib version? Could you share the data to test it? On the latest matplotlib source copy .- works nicely with a test plot like: plt.plot(np.random.random(100), .-) -- Gökhan -- 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 -- 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
[Matplotlib-users] Setting colors for hist
In the extended histogram demo: http://matplotlib.sourceforge.net/examples/pylab_examples/histogram_demo_extended.html?highlight=codex%20hist Multiple data are shown in parallel with different colors, using a single hist command. These colors seem to be automatically chosen, however, and I cannot figure out a way to control them. The color kwarg description says that it accepts matplotlib color arg or sequence of rgba tuples, but giving it a list of rgba tuples raises an error. Am I approaching this the wrong way? Has anybody successfully done this? Example that raises error: -- import pylab as P mu, sigma = 200, 25 x0 = mu + sigma*P.randn(1) x1 = mu + sigma*P.randn(7000) x2 = mu + sigma*P.randn(3000) # The following gives a ValueError from to_rgba n, bins, patches = P.hist([x0,x1,x2], 50, normed=1, histtype='bar', color=[(.5, 0., 0., 1.), (0., .5, 0., 1.),]) P.show() --- Many thanks, Jeff || Jeff Klukas, Research Assistant, Physics || University of Wisconsin -- Madison || jeff.klu...@gmail | jeffyklu...@aim | jeffklu...@skype || http://www.hep.wisc.edu/~jklukas/ -- 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] unconnected points (Michael Droettboom)
Hello, pylab.rcParams['path.simplify'] = false did the job. Thank you very much! -- 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] Bold Latex Tick-Labels
You can try: xticklabels = getp(gca(), 'xticklabels') yticklabels = getp(gca(), 'yticklabels') setp(xticklabels, fontsize=14, weight='bold') setp(yticklabels, fontsize=14, weight='bold') I've tried this, but since I've set rc('text', usetex=True), the ticklabels are only responsive to fontsize but not to weight. That is at least my experience. Am I doing something wrong? I've been trying to solve my problem by replacing the ticklabels with strings. I know this is a very inelegant workaround, but I am running out of ideas. I've tried two approaches that haven't worked successfully. (I don't get error messages, but nothing changes in the plot): Approach 1: x_labels = ['\boldmath $10^22$','\boldmath $10^23$','\boldmath $10^24$'] ax1.set_xticklabels(x_labels) Approach 2: Inspired by http://old.nabble.com/axis-on-top-for-barh-plot-td26549035.html this post : ax1.xaxis.set_major_locator(ticker.FixedLocator(range(3))) ax1.xaxis.set_major_formatter(ticker.FixedFormatter(x_labels)) Those are nice looking plots. It would be nice them to be shared on mpl's gallery or as an example :) Thanks! I'd be happy to share my code with everyone. It is not very nicely written, but I can fix it up. What steps should I take? Everything I've learned is from examples. This is just an amalgamation of expressions I've found on the web. Cheers, Daniel -- View this message in context: http://old.nabble.com/Bold-Latex-Tick-Labels-tp28037900p28045728.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- 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
[Matplotlib-users] Strange import error
Hi, I am trying to import pylab into an application running under an Apache wsgi server. The error I get is that if it tries to import matplotlib.cbook. The application can import numpy, scipy etc just fine. the error message is that matplotlib has no module cbook. I can import matplotlib OK but if a do a dir(matplolib) it does indeed not include cbook. If I try to import pylab from the command line it works fine and pylab.cbook is found. Any suggestions would be appreciated. K. Dere -- 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] Setting colors for hist
I was not aware of color cycles, but it looks like this is the way to go about solving my problem. Below is an example that actually works. -- import pylab as P mu, sigma = 200, 25 x0 = mu + sigma*P.randn(1) x1 = mu + sigma*P.randn(7000) x2 = mu + sigma*P.randn(3000) # Set the color cycle of the axes rather than using a kwarg P.gca().set_color_cycle([(0.5,0.,0.), (0.,0.5,0.), (0.,0.,0.5)]) n, bins, patches = P.hist([x0,x1,x2], 50, normed=1, histtype='bar') P.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] Strange import error
Hi, Does the box have multiple python versions installed, and are you sure that apache is using the same version and/or site packages as when you run it from the command line ? Regards, Rune V. Sjøen On Fri, Mar 26, 2010 at 8:07 PM, Ken Dere kpd...@verizon.net wrote: Hi, I am trying to import pylab into an application running under an Apache wsgi server. The error I get is that if it tries to import matplotlib.cbook. The application can import numpy, scipy etc just fine. the error message is that matplotlib has no module cbook. I can import matplotlib OK but if a do a dir(matplolib) it does indeed not include cbook. If I try to import pylab from the command line it works fine and pylab.cbook is found. Any suggestions would be appreciated. K. Dere -- 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 -- 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] Bold Latex Tick-Labels
On Fri, Mar 26, 2010 at 12:42 PM, konstellationen konstellatio...@gmail.com wrote: You can try: xticklabels = getp(gca(), 'xticklabels') yticklabels = getp(gca(), 'yticklabels') setp(xticklabels, fontsize=14, weight='bold') setp(yticklabels, fontsize=14, weight='bold') I've tried this, but since I've set rc('text', usetex=True), the ticklabels are only responsive to fontsize but not to weight. That is at least my experience. Am I doing something wrong? I've been trying to solve my problem by replacing the ticklabels with strings. I know this is a very inelegant workaround, but I am running out of ideas. I've tried two approaches that haven't worked successfully. (I don't get error messages, but nothing changes in the plot): Approach 1: x_labels = ['\boldmath $10^22$','\boldmath $10^23$','\boldmath $10^24$'] ax1.set_xticklabels(x_labels) Approach 2: Inspired by http://old.nabble.com/axis-on-top-for-barh-plot-td26549035.html this post : ax1.xaxis.set_major_locator(ticker.FixedLocator(range(3))) ax1.xaxis.set_major_formatter(ticker.FixedFormatter(x_labels)) Does it work with: plt.xticks((10**22, 10**23, 10**24), (r'$10^{22}$', r'$10^{23}$', r'$10^{24}$'), weight='extra bold') Those are nice looking plots. It would be nice them to be shared on mpl's gallery or as an example :) Thanks! I'd be happy to share my code with everyone. It is not very nicely written, but I can fix it up. What steps should I take? Everything I've learned is from examples. This is just an amalgamation of expressions I've found on the web. Cheers, Daniel Just prepare a self-running code, and add some documentation what is it good for. Later send an e-mail either here or to mpl-devel. Someone with commit access would be glad to include it in pylab_examples. -- Gökhan -- 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] Problems using bar() with left containing an array of float
2010/3/26 timothee cezard tcez...@staffmail.ed.ac.uk: does it make sense to use something like plt.bar(bins, nb_per_bin, width=(max(bins)-min(bins)) / (1.5*len(bins))) I think that should work, although you should use (max(bins) - min(bins) / 1.5 / (len(bins) - 1), but I would suggest: bounds = {some N + 1 array} center = 0.5 * (bounds[1:] + bounds[:-1]) width = 0.9 * (bounds[1:] - bounds[:-1]) offset = 0.5 * width plt.bar(center - offset, {some N array}, width = width) but I haven't tested it. bar() does accept an iterable as *width* argument. Friedrich -- 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
[Matplotlib-users] SciPy 2010 Tutorials: brainstorming and call for proposals
Greetings everyone, This year, there will be two days of tutorials (June 28th and 29th) before the main SciPy 2010 conference. Each of the two tutorial tracks (intro, advanced) will have a 3-4 hour morning and afternoon session both days, for a total of 4 intro sessions and 4 advanced sessions. The main tutorial web page for SciPy 2010 is here: http://conference.scipy.org/scipy2010/tutorials.html We are currently in the process of planning the tutorial sessions. You can help us in two ways: Brainstorm/vote on potential tutorial topics To help us plan the tutorials, we have setup a web site that allow everyone in the community to brainstorm and vote on tutorial ideas/topics. The website for brainstorming/voting is here: http://conference.scipy.org/scipy2010/tutorialsUV.html The tutorial committee will use this information to help select the tutorials. Please jump in and let us know what tutorial topics you would like to see. Tutorial proposal submissions = We are now accepting tutorial proposals from individuals or teams that would like to present a tutorial. Tutorials should be focused on covering a well defined topic in a hands on manner. We want to see tutorial attendees coding! We are pleased to offer tutorial presenters stipends this year for the first time: * 1 Session: $1,000 (half day) * 2 Sessions: $1,500 (full day) Optionally, part of this stipend can be applied to the presenter's registration costs. To submit a tutorial proposal please submit the following materials to 2010tutori...@scipy.org by April 15: * A short bio of the presenter or team members. * Which track the tutorial would be in (intro or advanced). * A short description and/or outline of the tutorial content. * A list of Python packages that attendees will need to have installed to follow along. -- 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
[Matplotlib-users] Making a data-driven colormap
Hi everyone, I am trying to make a color-map which will respond to the range of values in the data itself. That is - I want to take one of the mpl colormaps and use parts of it, depending on the range of the data. In particular, I am interested in using the plt.cm.RdYlBu_r colormap. If the data has both negative and positive values, I want 0 to map to the central value of this colormap (a pale whitish yellow) and I want negative values to be in blue and positive numbers to be in red. Also - I would want to use the parts of the colormap that represent how far away the smallest and largest values in the data are from 0. So - if my data is in the range [x1,x2] I would want to use the part of the colormap in indices 127-127*abs(x1)/(x2-x1) through 127+127*x2/(x2-x1). If the data only includes positive numbers, I would want to only use the blue part of the colormap and if there are negative numbers, I would want to only use the red part of the colormap (in these cases, I would also want to take only a portion of the colormap which represents the size of the interval [x1,x2] relative to the interval [0,x1] or [x2,0], as the case may be). I think that this might be useful when comparing matrices generated from different data, but with the same computation, such as correlation or coherence (see http://nipy.sourceforge.net/nitime/examples/fmri.html to get an idea of what I mean). First of all - is this a good idea? Or in other words - is there any reason I am not thinking of why this idea is a really bad idea? Second - the technical questions. I think that I can make this happen by using matplotlib.colors.LinearSegmentedColormap, after fiddling with the values of the color-map a bit (as described above), but in order to do that, I need to know what segmentdata was used in order to generate the original colormap (for example, how many lines did each of the entries in the cdict have? Looking at a plot of the cmap it looks like there must have been 8 or 9 for RdYlBu_r, but I can't be sure). I could analyze it in more detail to get that out empirically, but I am guessing that someone around here might be able to spare me that lunacy (if not others...). Thanks in advance, Ariel -- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel -- 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