From: C M <cmp...@gm...> - 2012-07-21 03:55:58
|
How possible would it be to wrap y axis tick labels after a certain text length? I have a horizontal bar plot where some bars' labels are too long and therefore cut off. I can scrunch the width of the whole plot to accommodate them, but I'd much rather wrap long text and allow a little more space to accommodate two lines. For examples: I'd like to go from this: a short axis label | ====================== A very long axis label that gets cut off | ============= To this: a short axis label | ====================== A very long axis label | ============= that gets cut off Is this possible or has it ever been done? Thanks, Che |
From: Benjamin R. <ben...@ou...> - 2012-07-21 04:16:07
|
On Fri, Jul 20, 2012 at 10:55 PM, C M <cmp...@gm...> wrote: > How possible would it be to wrap y axis tick labels after a certain > text length? I have a horizontal bar plot where some bars' labels are > too long and therefore cut off. I can scrunch the width of the whole > plot to accommodate them, but I'd much rather wrap long text and allow > a little more space to accommodate two lines. For examples: > > I'd like to go from this: > > a short axis label | ====================== > > A very long axis label that gets cut off | ============= > > > To this: > a short axis label | ====================== > > A very long axis label | ============= > that gets cut off > > > Is this possible or has it ever been done? > > Thanks, > Che > > Not automatically, but you can always manually break up a line of text with a '\n' in the string. Automatic/intelligent line wrapping has always been a requested feature, but would be very difficult to implement correctly. Therefore, the recommendation is for manual usage of newlines. Cheers! Ben Root |
From: Mark L. <bre...@ya...> - 2012-07-21 11:33:31
|
On 21/07/2012 05:15, Benjamin Root wrote: > On Fri, Jul 20, 2012 at 10:55 PM, C M <cmp...@gm...> wrote: > >> How possible would it be to wrap y axis tick labels after a certain >> text length? I have a horizontal bar plot where some bars' labels are >> too long and therefore cut off. I can scrunch the width of the whole >> plot to accommodate them, but I'd much rather wrap long text and allow >> a little more space to accommodate two lines. For examples: >> >> I'd like to go from this: >> >> a short axis label | ====================== >> >> A very long axis label that gets cut off | ============= >> >> >> To this: >> a short axis label | ====================== >> >> A very long axis label | ============= >> that gets cut off >> >> >> Is this possible or has it ever been done? >> >> Thanks, >> Che >> >> > Not automatically, but you can always manually break up a line of text with > a '\n' in the string. Automatic/intelligent line wrapping has always been > a requested feature, but would be very difficult to implement correctly. > Therefore, the recommendation is for manual usage of newlines. For the OP an example is here http://matplotlib.sourceforge.net/examples/pylab_examples/barchart_demo2.html > > Cheers! > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Cheers. Mark Lawrence. |
From: Jonathan S. <js...@cf...> - 2012-07-23 12:57:00
|
You might want to look at the python textwrap module. That can take your labels and automatically wrap them at a certain column width. See (in addition to the official python docs) http://www.doughellmann.com/PyMOTW/textwrap/ Jon On Fri, 2012-07-20 at 23:55 -0400, C M wrote: > How possible would it be to wrap y axis tick labels after a certain > text length? I have a horizontal bar plot where some bars' labels are > too long and therefore cut off. I can scrunch the width of the whole > plot to accommodate them, but I'd much rather wrap long text and allow > a little more space to accommodate two lines. For examples: > > I'd like to go from this: > > a short axis label | ====================== > > A very long axis label that gets cut off | ============= > > > To this: > a short axis label | ====================== > > A very long axis label | ============= > that gets cut off > > > Is this possible or has it ever been done? > > Thanks, > Che > > -- ______________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA js...@cf... 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA ______________________________________________________________ |