Re: [Matplotlib-users] How to plot only a legend?

2012-07-27 Thread Andreas Hilboll
 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.

Thanks for your help, guys! I wasn't totally happy with the 'tight'
bounding box, as the margins to the legend were not uniform on all four
sides. So I did indeed return to a subprocess.call(['pdfcrop', ...]).

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


[Matplotlib-users] How to plot only a legend?

2012-07-26 Thread Andreas Hilboll
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?

2012-07-26 Thread Francesco Montesano
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?

2012-07-26 Thread Andreas Hilboll
 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?

2012-07-26 Thread Daπid
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?

2012-07-26 Thread Damon McDougall
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?

2012-07-26 Thread Francesco Montesano
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