[Matplotlib-users] Changing the Dash Spacing?
Hello all, I would like to make small figures (about 3 wide) so that they are exactly the right size for a LaTeX document I am preparing. This should be straightforward, but I fear I am running into inherent limitations in the matplotlib design. The particular problem is that the dash spacing for dashed lines seems to be fixed to a certain number of points. This looks fine for default figure sizes, but in a small figure, the dash length becomes comparable to the width of histogram bars I'm producing, so the output just looks like a series of unrelated scribbles rather than a coherent histogram. I've produced a short program below which gives a minimal demonstration of the problem. Is there some way to change the length of dashes? Currently, I am hacking together a solution which involves making large figures with huge font sizes, but I would much rather be able to match font sizes exactly by making the figure the right size in the first place. Many thanks, Jeff || Jeff Klukas, Physics || University of Wisconsin || http://jeff.klukas.net - import matplotlib.pyplot as plt fig = plt.figure(figsize=(6,4)) plt.plot(range(20), range(20), linestyle='steps--') plt.savefig('dashdemo') fig = plt.figure(figsize=(3,2)) plt.plot(range(20), range(20), linestyle='steps--') plt.savefig('dashdemosmall') -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Error with PDF output with usetex
On Sun, Aug 21, 2011 at 1:01 PM, Jouni K. Seppänen j...@iki.fi wrote: Jeff Klukas klu...@wisc.edu writes: File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/dviread.py, line 727, in _register assert encoding is None AssertionError This sounds like this issue: https://github.com/matplotlib/matplotlib/issues/191 There is a workaround in git commit 708c451 (patch below), which you could apply to your local copy of dviread. It works! Thanks for a simple fix. || Jeff Klukas, Research Assistant || Dept. of Physics, Univ. of Wisconsin || http://jeff.klukas.net -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Error with PDF output with usetex
On Tue, Aug 16, 2011 at 4:22 AM, Damon McDougall d.mcdoug...@warwick.ac.uk wrote: Hi Jeff, I am able to run the tex_demo.py with no problems and I can create output files using the Agg backend. When I try to use the PDF backend, however, I get an error which stems from dviread.py (pasted below). Any thoughts on what could be going wrong? Thanks! Jeff Hi Jeff, How did you install matplotlib? From source yourself? No, I'm using the Enthought Python Distribution (EPD64). And when you installed matplotlib, did it see that you had dvipng installed? FYI, you can do which dvipng to return the path where dvipng lives (if it is in your path already) or you can do locate dvipng to do a search for the binary if it isn't already in your path. P.S. You forgot to reply-all so everyone can see your response. $ which dvipng /usr/texbin/dvipng I don't remember any complaints while running the EPD installer. Would there be a way to check this? Is the problem definitely related to an inability to find dvipng, or could there be other possibilities? Thanks, Jeff I had a similar problem. I don't think it's an inability to find dvipng, I think it's that it couldn't find dvipng when matplotlib was built. When matplotlib builds there'll be a section of text sent to stdout under the heading of 'OPTIONAL DEPENDENCIES', there it will tell you whether it found dvipng when it was building. Are you able to find this? If not, are there install logs saved somewhere after you installed matplotlib? I'm not able to find this. The EPD installer comes as a Mac .pkg application which seems to hide everything that's going on. It saves Receipts, but these don't contain the kind of logs we're looking for, as far as I can tell. On my previous laptop, I was using OS X Snow Leopard with python and matplotlib from an older EPD version, and I had no troubles. Perhaps I need to ask the Enthought folks. Thanks, Jeff -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Error with PDF output with usetex
Hello all, I am running Mac OS X 10.7 Lion with matplotlib 1.0.1 and the MacTex 2011 distrubution. I am able to run the tex_demo.py with no problems and I can create output files using the Agg backend. When I try to use the PDF backend, however, I get an error which stems from dviread.py (pasted below). Any thoughts on what could be going wrong? Thanks! Jeff || Jeff Klukas || Research Assistant (Physics), University of Wisconsin || jeff.klukas@gmail | jeffyklukas@aim | jeffklukas@skype || http://hep.wisc.edu/~jklukas/ Traceback (most recent call last): File tex_demo.py, line 32, in module savefig('tex_demo') File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/pyplot.py, line 363, in savefig return fig.savefig(*args, **kwargs) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/figure.py, line 1084, in savefig self.canvas.print_figure(*args, **kwargs) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/backend_bases.py, line 1923, in print_figure **kwargs) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py, line 2156, in print_pdf self.figure.draw(renderer) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/figure.py, line 798, in draw func(*args) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/axes.py, line 1946, in draw a.draw(renderer) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/axis.py, line 1017, in draw tick.draw(renderer) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/axis.py, line 234, in draw self.label1.draw(renderer) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/text.py, line 571, in draw self._fontproperties, angle) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py, line 1549, in draw_tex psfont = self.tex_font_mapping(dvifont.texname) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py, line 1365, in tex_font_mapping dviread.PsfontsMap(dviread.find_tex_file('pdftex.map')) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/dviread.py, line 668, in __init__ self._parse(file) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/dviread.py, line 701, in _parse self._register(words) File /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/matplotlib/dviread.py, line 727, in _register assert encoding is None AssertionError -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Error with PDF output with usetex
On Mon, Aug 15, 2011 at 10:00 PM, Damon McDougall d.mcdoug...@warwick.ac.uk wrote: Hi Jeff, I am able to run the tex_demo.py with no problems and I can create output files using the Agg backend. When I try to use the PDF backend, however, I get an error which stems from dviread.py (pasted below). Any thoughts on what could be going wrong? Thanks! Jeff Hi Jeff, How did you install matplotlib? From source yourself? No, I'm using the Enthought Python Distribution (EPD64). And when you installed matplotlib, did it see that you had dvipng installed? FYI, you can do which dvipng to return the path where dvipng lives (if it is in your path already) or you can do locate dvipng to do a search for the binary if it isn't already in your path. P.S. You forgot to reply-all so everyone can see your response. $ which dvipng /usr/texbin/dvipng I don't remember any complaints while running the EPD installer. Would there be a way to check this? Is the problem definitely related to an inability to find dvipng, or could there be other possibilities? Thanks, Jeff -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Changing the font
On Thu, Apr 1, 2010 at 11:21 AM, Alex S schmitt.happ...@gmail.com wrote: Hi there, I'm trying to change the font default on my graph to New Century Schoolbook. I'm trying to do this by editing the matplotlibrc file. Unfortunately, although I'm able to change the font.family, I can't figure out how to make it use something other than the default in the family... I tried changing the list further down to only include the font I want, like this: font.serif : New Century Schoolbook #Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif (note I commented out the other fonts, just rearranging the list to put New Century Schoolbook first didn't seem to work either) Could anyone tell me what I'm doing wrong? The default font family is sans-serif, so you also need to add: font.family : serif I think that should solve the problem. Cheers, Jeff -- 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] 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
[Matplotlib-users] Tick labels in mplot3d?
I would like to add tick labels to a 3d plot, but so far have had no luck. I would like to start with something like the bars3d example: http://matplotlib.sourceforge.net/examples/mplot3d/bars3d_demo.html But I would like to have each bar chart labeled by its tick on the y-axis. The traditional ax.yaxis.set_ticklabels() method has no effect, and the ax.yaxis.set_ticks() just messes up the output catastrophically. My attempt at modifying the example is below. Any thoughts? Thanks, Jeff --- from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = Axes3D(fig) for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]): xs = np.arange(20) ys = np.random.rand(20) ax.bar(xs, ys, zs=z, zdir='y', color=c, alpha=0.8) ## My changes ax.yaxis.set_ticks([0, 10, 20, 30]) # This totally screws things up ax.yaxis.set_ticklabels(['first', 'second', 'third', 'fourth']) # This does absolutely nothing ## End my changes ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') plt.show() || 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] Polar 3D plot?
The code below works perfectly. I think this should be included as an mplot3d codex. I'll look into what's required to submit a new example to the documentation. Thanks Armin! || Jeff Klukas, Research Assistant, Physics || University of Wisconsin -- Madison || jeff.klu...@gmail | jeffyklu...@aim | jeffklu...@skype || http://www.hep.wisc.edu/~jklukas/ On Thu, Mar 18, 2010 at 9:42 AM, Armin Moser armin.mo...@student.tugraz.at wrote: Hi, you can create your supporting points on a regular r, phi grid and transform them then to cartesian coordinates: from mpl_toolkits.mplot3d import Axes3D import matplotlib import numpy as np from matplotlib import cm from matplotlib import pyplot as plt step = 0.04 maxval = 1.0 fig = plt.figure() ax = Axes3D(fig) # create supporting points in polar coordinates r = np.linspace(0,1.25,50) p = np.linspace(0,2*np.pi,50) R,P = np.meshgrid(r,p) # transform them to cartesian system X,Y = R*np.cos(P),R*np.sin(P) Z = ((R**2 - 1)**2) ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet) ax.set_zlim3d(0, 1) ax.set_xlabel(r'$\phi_\mathrm{real}$') ax.set_ylabel(r'$\phi_\mathrm{im}$') ax.set_zlabel(r'$V(\phi)$') ax.set_xticks([]) plt.show() hth Armin klukas schrieb: I'm guessing this is currently impossible with the current mplot3d functionality, but I was wondering if there was any way I could generate a 3d graph with r, phi, z coordinates rather than x, y, z? The point is that I want to make a figure that looks like the following: http://upload.wikimedia.org/wikipedia/commons/7/7b/Mexican_hat_potential_polar.svg Using the x, y, z system, I end up with something that has long tails like this: http://upload.wikimedia.org/wikipedia/commons/4/44/Mecanismo_de_Higgs_PH.png If I try to artificially cut off the data beyond some radius, I end up with jagged edges that are not at all visually appealing. I would appreciate any crazy ideas you can come up with. Thanks, Jeff P.S. Code to produce the ugly jaggedness is included below: --- from mpl_toolkits.mplot3d import Axes3D import matplotlib import numpy as np from matplotlib import cm from matplotlib import pyplot as plt step = 0.04 maxval = 1.0 fig = plt.figure() ax = Axes3D(fig) X = np.arange(-maxval, maxval, step) Y = np.arange(-maxval, maxval, step) X, Y = np.meshgrid(X, Y) R = np.sqrt(X**2 + Y**2) Z = ((R**2 - 1)**2) * (R 1.25) ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet) ax.set_zlim3d(0, 1) #plt.setp(ax.get_xticklabels(), visible=False) ax.set_xlabel(r'$\phi_\mathrm{real}$') ax.set_ylabel(r'$\phi_\mathrm{im}$') ax.set_zlabel(r'$V(\phi)$') ax.set_xticks([]) plt.show() -- Armin Moser Institute of Solid State Physics Graz University of Technology Petersgasse 16 8010 Graz Austria Tel.: 0043 316 873 8477 -- 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