Re: [Matplotlib-users] Prevent matplotlib (imshow) from interpolating at all
Great tip, alot simpler than i expected. Although you still need to specify the correct dimensions of the axes, otherwise it wil be interpolated after all. If in my example i increase the figsize by a factor of 2, the image stretches along with it. Thanks! Rutger On 25 July 2012 19:11, Benjamin Root ben.r...@ou.edu wrote: If you are using v1.1.0 or later, you can set interpolation to none. Note the difference between providing the string none, which means to do no interpolation at all, while the python None means to do the default. Ben Root -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] axvspan with dates on x-axis
Luciano got in touch offline and my suggestions worked for a certain version of Python. Luciano, were you trying it in python3? If not, what version of Python was it that wasn't working for you? Thanks, On 24 July 2012 18:26, Luciano Fleischfresser l_...@yahoo.com wrote: Still not working. The output looks like this: File NotasFaltasdoisgraficos.py, line 58 ax3.axvspan(*mdates.datestr2num(['05/18/2012', '06/30/2012']), facecolor='g', alpha=0.5) ^ SyntaxError: invalid syntax When you say ...change the months to short English form you mean in the data file? That is, Abr - Apr, Mai - May??? ...still did not work. From: Phil Elson pelson@gmail.com To: Luciano Fleischfresser l...@utfpr.edu.br Cc: Matplotlib-users@lists.sourceforge.net Matplotlib-users@lists.sourceforge.net Sent: Monday, July 23, 2012 5:45 PM Subject: Re: [Matplotlib-users] axvspan with dates on x-axis Looks like your very close. I needed to change the months to short English form, change the line ax3.grid('True') to ax3.grid(True) and add the line ax3.axvspan(*mdates.datestr2num(['05/18/2012', '06/30/2012']), facecolor='g', alpha=0.5) To get the box on the lower plot. Hope that helps, On 23 July 2012 20:42, Luciano Fleischfresser l_...@yahoo.com wrote: I want to place a colored vertical range on my plot and came across the following example: http://stackoverflow.com/questions/8270981/in-a-matplotlib-plot-can-i-highlight-specific-x-value-ranges/8271438#8271438 It shows what I am trying to do using axvspan. However, I was not able to reproduce the second plot with dates. Errors like 'invalid syntax' for color='red' and others prevented me from reproducing the plot. The demo from Matplotlib gallery worked fine for me. My plot also has dates on the x-axis. I am attaching code and data file. Hope someone can point me in the right direction. L Fleischfresser -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] axvspan with dates on x-axis
It is Python 2.5.2 (r252.60911, Jan 24 2010, 14:53:14) [GCC 4.3.2] on linux2. I believe the Matplotlib version there is outdated or the locale is an issue. Thanks for the help! From: Phil Elson pelson@gmail.com To: Luciano Fleischfresser l...@utfpr.edu.br Cc: Matplotlib-users@lists.sourceforge.net Matplotlib-users@lists.sourceforge.net Sent: Thursday, July 26, 2012 5:02 AM Subject: Re: [Matplotlib-users] axvspan with dates on x-axis Luciano got in touch offline and my suggestions worked for a certain version of Python. Luciano, were you trying it in python3? If not, what version of Python was it that wasn't working for you? Thanks, On 24 July 2012 18:26, Luciano Fleischfresser l_...@yahoo.com wrote: Still not working. The output looks like this: File NotasFaltasdoisgraficos.py, line 58 ax3.axvspan(*mdates.datestr2num(['05/18/2012', '06/30/2012']), facecolor='g', alpha=0.5) ^ SyntaxError: invalid syntax When you say ...change the months to short English form you mean in the data file? That is, Abr - Apr, Mai - May??? ...still did not work. From: Phil Elson pelson@gmail.com To: Luciano Fleischfresser l...@utfpr.edu.br Cc: Matplotlib-users@lists.sourceforge.net Matplotlib-users@lists.sourceforge.net Sent: Monday, July 23, 2012 5:45 PM Subject: Re: [Matplotlib-users] axvspan with dates on x-axis Looks like your very close. I needed to change the months to short English form, change the line ax3.grid('True') to ax3.grid(True) and add the line ax3.axvspan(*mdates.datestr2num(['05/18/2012', '06/30/2012']), facecolor='g', alpha=0.5) To get the box on the lower plot. Hope that helps, On 23 July 2012 20:42, Luciano Fleischfresser l_...@yahoo.com wrote: I want to place a colored vertical range on my plot and came across the following example: http://stackoverflow.com/questions/8270981/in-a-matplotlib-plot-can-i-highlight-specific-x-value-ranges/8271438#8271438 It shows what I am trying to do using axvspan. However, I was not able to reproduce the second plot with dates. Errors like 'invalid syntax' for color='red' and others prevented me from reproducing the plot. The demo from Matplotlib gallery worked fine for me. My plot also has dates on the x-axis. I am attaching code and data file. Hope someone can point me in the right direction. L Fleischfresser -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to plot only a legend?
Hi, I would like to create a figure which only contains a legend, and no axes at all. I would like to manually assign the colors. I found this here: http://stackoverflow.com/a/3302666 but from there on, I'd like to remove the axes, and put the legend into three columns. Any help is greatly appreciated :) Andreas. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to plot only a legend?
Hi Andreas, 2012/7/26 Andreas Hilboll li...@hilboll.de: Hi, I would like to create a figure which only contains a legend, and no axes at all. I would like to manually assign the colors. I found this here: http://stackoverflow.com/a/3302666 but from there on, I'd like to remove the axes, and put the legend into three columns. If the plot attached it's fine for you it's easy: import matplotlib.pyplot as plt ax = plt.subplot() #create the axes ax.set_axis_off() #turn off the axis #do patches and labels ax.legend(patches, labels, ...) #legend alone in the figure plt.show() Cheers, Francesco Any help is greatly appreciated :) Andreas. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users test.pdf Description: Adobe PDF document -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to plot only a legend?
Hi Andreas, 2012/7/26 Andreas Hilboll li...@hilboll.de: Hi, I would like to create a figure which only contains a legend, and no axes at all. I would like to manually assign the colors. I found this here: http://stackoverflow.com/a/3302666 but from there on, I'd like to remove the axes, and put the legend into three columns. If the plot attached it's fine for you it's easy: import matplotlib.pyplot as plt ax = plt.subplot() #create the axes ax.set_axis_off() #turn off the axis #do patches and labels ax.legend(patches, labels, ...) #legend alone in the figure plt.show() Cheers, Francesco That's really easy :) I could live with this solution, applying some external tool like pdfcrop to the result. Of course, it would be nicer if the PDF's page size would be exactly that of the legend (plus some margin), so that I wouldn't have to resort to external tools ... Any ideas? Cheers, A. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to plot only a legend?
On Thu, Jul 26, 2012 at 5:05 PM, Andreas Hilboll li...@hilboll.de wrote: That's really easy :) I could live with this solution, applying some external tool like pdfcrop to the result. If you can use other output, you can generate a png image, which would be easier to cut (even inside MPL.image). This, without entering in more complicated issues, that I don't know if they are even possible. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to plot only a legend?
On Thu, Jul 26, 2012 at 06:05:39PM +0200, Andreas Hilboll wrote: Hi Andreas, 2012/7/26 Andreas Hilboll li...@hilboll.de: Hi, I would like to create a figure which only contains a legend, and no axes at all. I would like to manually assign the colors. I found this here: http://stackoverflow.com/a/3302666 but from there on, I'd like to remove the axes, and put the legend into three columns. If the plot attached it's fine for you it's easy: import matplotlib.pyplot as plt ax = plt.subplot() #create the axes ax.set_axis_off() #turn off the axis #do patches and labels ax.legend(patches, labels, ...) #legend alone in the figure plt.show() Cheers, Francesco That's really easy :) I could live with this solution, applying some external tool like pdfcrop to the result. Of course, it would be nicer if the PDF's page size would be exactly that of the legend (plus some margin), so that I wouldn't have to resort to external tools ... Any ideas? How about plt.savefig('roflcakes.png', bbox_inches='tight', pad_inches=0.1) Since the other artists are invisible, that should crop to just your legend. I'm assuming matplotlib updates the BoundingBox such that it doesn't include invisible artists. Cheers, A. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Damon McDougall http://damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to plot only a legend?
Hi, you should be also able to create the axes as: ax = plt.figure( figsize=(x,y) ).add_subplot(111) with figsize big enough to fit just the legend Cheers Francesco 2012/7/26 Damon McDougall damon.mcdoug...@gmail.com: On Thu, Jul 26, 2012 at 06:05:39PM +0200, Andreas Hilboll wrote: Hi Andreas, 2012/7/26 Andreas Hilboll li...@hilboll.de: Hi, I would like to create a figure which only contains a legend, and no axes at all. I would like to manually assign the colors. I found this here: http://stackoverflow.com/a/3302666 but from there on, I'd like to remove the axes, and put the legend into three columns. If the plot attached it's fine for you it's easy: import matplotlib.pyplot as plt ax = plt.subplot() #create the axes ax.set_axis_off() #turn off the axis #do patches and labels ax.legend(patches, labels, ...) #legend alone in the figure plt.show() Cheers, Francesco That's really easy :) I could live with this solution, applying some external tool like pdfcrop to the result. Of course, it would be nicer if the PDF's page size would be exactly that of the legend (plus some margin), so that I wouldn't have to resort to external tools ... Any ideas? How about plt.savefig('roflcakes.png', bbox_inches='tight', pad_inches=0.1) Since the other artists are invisible, that should crop to just your legend. I'm assuming matplotlib updates the BoundingBox such that it doesn't include invisible artists. Cheers, A. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Damon McDougall http://damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plt.figure.show() not working in Ubuntu
Hi all, I am getting the following error message: 'Figure' object has no attribute 'show' When running matplotlib in Ubuntu 12.04, with matplotlib 1.2.x and pylab 1.6.2. The code is set up as such: fig = pylab.figure() ... fig.show() This works fine on Mac OSX 10.6 with matplotlib 1.1.0 and pylab 1.6.1 Any thoughts or similar experiences? Thanks! Josh -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plt.figure.show() not working in Ubuntu
On Thursday, July 26, 2012, Joshua Koehler wrote: Hi all, I am getting the following error message: 'Figure' object has no attribute 'show' When running matplotlib in Ubuntu 12.04, with matplotlib 1.2.x and pylab 1.6.2. The code is set up as such: fig = pylab.figure() ... fig.show() This works fine on Mac OSX 10.6 with matplotlib 1.1.0 and pylab 1.6.1 Any thoughts or similar experiences? Thanks! Josh I doubt that ever should have worked. If it did, then something was seriously messed up. Also, note there isnt really a package called pylab. There is a special sub-module in matplotlib called pylab, that you typically do from pylab import * with. The version number you are giving more likely corresponds to the numpy version number. The show() function is a part of the pyplot and pylab namespaces. Ben Root -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] ValueError: x and y must have same first dimension
Hi I have a code to plot a histogram and I am trying to add a best fit line following this example http://matplotlib.sourceforge.net/examples/pylab_examples/histogram_demo.html but run into this error Traceback (most recent call last): File /home/Astro/count_Histogram.py, line 54, in module l = plt.plot(bins, y, 'r--', linewidth=1) File /usr/lib/pymodules/python2.7/matplotlib/pyplot.py, line 2467, in plot ret = ax.plot(*args, **kwargs) File /usr/lib/pymodules/python2.7/matplotlib/axes.py, line 3893, in plot for line in self._get_lines(*args, **kwargs): File /usr/lib/pymodules/python2.7/matplotlib/axes.py, line 322, in _grab_next_args for seg in self._plot_args(remaining, kwargs): File /usr/lib/pymodules/python2.7/matplotlib/axes.py, line 300, in _plot_args x, y = self._xy_from_xy(x, y) File /usr/lib/pymodules/python2.7/matplotlib/axes.py, line 240, in _xy_from_xy raise ValueError(x and y must have same first dimension) ValueError: x and y must have same first dimension My Code import matplotlib.pyplot as plt import math import numpy as np import mpl_toolkits.mplot3d.axes3d import matplotlib.mlab as mlab counts = [] F = '/home/Astro/outfiles/outmag21_5dr_38_68.txt' f = open(F) for line in f: if line != ' ': columns = line.split() count = columns[3] count = int(count) counts.append(count) C = np.array(counts, dtype=float) avg = sum(C)/len(C) diff = C-avg sigma = np.sqrt((1./len(C))*(diff**2)) bins = 20 plt.hist(C, bins, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log = False, color=None, label=None) plt.title() plt.text(25,20,'M -21.5' '\n' 'N Halos 3877' '\n' 'Length Cell 38.68Mpc' '\n' 'N Cells 269' '\n' 'Avg Halo per Cell 14.35 ') plt.xlabel(Halos/Cell) plt.ylabel(Number Cells with N Halos) y = mlab.normpdf( bins, avg, sigma) print(len(y)) l = plt.plot(bins, y, 'r--', linewidth=1) plt.show() My first question is do x and y refer to the values in l = plt.plot(bins, y, 'r--', linewidth=1) which for my case are bins and y? if that is the case how can I get then to be the same first dimension? -- View this message in context: http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34218704.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Bug in colorbar()
I am trying to make a plot with a colorbar that has a reduced axis over which the colorbar is executed. This is set via passing in a norm to contourf: logNorm = colors.Normalize(vmax=0,vmin=-100) surf = ax.contourf(X,Y,logZ, map_scale, cmap=cm.jet, norm=logNorm) The output of this will have the colorbar extend to the full range of the data and not limited by the norm set: cbar = fig.colorbar(surf, shrink=0.70, aspect=36, fraction=.15,pad=.03) so I assumed modifying by setting the norm like this would do the trick: cbar = fig.colorbar(surf, shrink=0.70, aspect=36, fraction=.15,pad=.03, norm=logNorm) This isn't what happens. norm has no effect. The norm is recognized but not passed to ColorbarBase is my guess from doing this instead to get the desired effect: axcb, _ = mpl.colorbar.make_axes_gridspec(ax, shrink=0.7) cbar = mpl.colorbar.ColorbarBase(axcb, cmap=cm.jet, norm=logNorm) Is this a bug or any reason why the norm is not passed through if specified in colorbar?? -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users