Francesco Montesano, on 2011-03-17 12:05, wrote: > Dear all, > > I have a rather complex code that takes a list of file names and of > legend tags from command line and compute contour plots > > ./contour_plots.py [options] filename1 ... filename2 tag1 ... tagn > > The codes make filled contours at required levels, then line contours. > >From the latter I extract one line from each file and create a legend > > spl.legend(lines, [tag1...tagn], other options) > > All it works fine. The only problem is that sometimes I have tags that > are long and I would like to be able to break between multiple lines. > In examples/legend_demo3.py is shown that 'ax1.plot([1], > label="multi\nline")' the \n is interpreted (correctly) as new line. > > Normaly I have something like > ./contour_plots.py [options] filename1 \(long\)tag\$_\{very long\}\$ > that gives me a legend with the correct formatting. If I try to add a > '\n' after 'tag', I get out the tag as before plus a 'n' after 'tag'. > I've tried to enclose the whole string or just \n in "" or r"" but > nothing good happens (either I get 'n' or 'rn'). > Is there a way to do what I want to do?
Hi Francesco, If you are using bash, you can insert newlines using the Enter/Return key if you start an argument with a quote like this: $ cat commandline.py #!/usr/bin/env python import sys print "Program output:", sys.argv print sys.argv[-1] $ ./commandline.py "something with newlines" Program output: ['./commandline.py', 'something\nwith\nnewlines'] something with newlines best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
signature.asc
Description: Digital signature
------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users