Re: [Matplotlib-users] Matplotlib V1.3 suptitle
On 08/23/2013 11:31 AM, Benjamin Root wrote: On Fri, Aug 23, 2013 at 11:21 AM, Peter Bloomfield mailto:peter.bloomfi...@camhpet.ca>> wrote: On 08/23/2013 10:43 AM, Benjamin Root wrote: On Fri, Aug 23, 2013 at 9:57 AM, Peter Bloomfield mailto:peter.bloomfi...@camhpet.ca>> wrote: Good morning, I am running openSuSE 12.2, and this morning I upgraded matplotlib to v1.3, and now I am having a problem with suptitle. I use the following lines to put a title and legend onto a plot figure import matplotlib.pyplot as plt plt.figure(1) plt.suptitle( "Study# : " + os.path.basename( inImage_IO.IO_FileName ) + \ "\n" + "{ Acquired : " + \ AcqDateTime.strftime( "%b %d, %Y - $T_o$ @ %H:%M:%S" ) + " }", \ y=0.98, weight="roman", size="large" ) plt.suptitle( "{Creation Date : " + AnalysisTOD + "}", x=0.86, y=0.03, weight="roman", size="x-small" ) Under v1.3, I only get the 'Creation Date : ...' text at the bottom of the figure the 'Study# ...' string is not present at the top. If I change it to import matplotlib.pyplot as plt plt.figure(1) plt.suptitle( "Study# : ", y=0.98, weight="roman", size="large" ) plt.suptitle( "{Creation Date : " + AnalysisTOD + "}", x=0.86, y=0.03, weight="roman", size="x-small" ) the 'Creation Date : ...' text at the bottom of the figure the 'Study# : ' string is at the top. So the problem is in the string construct in the first example. Does anybody know of a way to get around this? Thanks in advance Peter Oh, wow... we didn't think anybody was using that "misfeature". This was a bug we fixed for 1.3, in that users complained that calling plt.title() would update an existing title, but plt.suptitle() would not (multiple calls would just result in text overlaid on top of each other). We fixed this for 1.3 so that there is a single text object that is kept and is revised in subsequent calls to suptitle(). To get what you want, you will have to consolidate those strings into one. Cheers! Ben Thanks for getting back to me, but I have tried to do as you suggest, but to no avail, and here I apologise for my lack of knowledge of python/matplotlib. I consolidated the strings into one, titleStr titleStr = "Study# : " + os.path.basename( inImage_IO.IO_FileName ) + \ "\n" + "{ Acquired : " + \ AcqDateTime.strftime( "%b %d, %Y - $T_o$ @ %H:%M:%S" ) + " }" plt.suptitle( titleStr, y=0.98, weight="roman", size="large" ) which should write the string 'Study# : Pos9.img\n{ Acquired : Feb 18, 2003 - $T_o$ @ 14:55:02 }' at the top of the figure, but it did not, so I thought it is the "\n", and tried titleStr = "Study# : " + os.path.basename( inImage_IO.IO_FileName ) plt.suptitle( titleStr, y=0.98, weight="roman", size="large" ) which should write the string 'Study# : Pos9.img' and this again failed to write the suptitle in the figure. Am I being dumb (rhetorical)? What is the best way to consolidate the strings to work with suptitle, many thanks in advance. Cheers Peter No issues here. Let's try simplifying it further and further. Try the following script. import matplotlib.pyplot as plt plt.suptitle("Study# : Pos9.img") plt.show() Does that work for you? If it does, iterate on that code example, adding pieces back into it and see when it breaks. Ben Root The example works, and changing it to import matplotlib.pyplot as plt plt.suptitle( "Study# : Pos9.img\n{ Acquired : Feb 18, 2003 - $T_o$ @ 14:55:02 }") plt.show() also works. Though now, I need to apologise, in my original email I should have added that I am using from matplotlib.backends.backend_pdf import PdfPages to write a pdf file of the save the figure. I extended the example to a small script from matplotlib.backends.backend_pdf import PdfPages import matplotlib.pyplot as plt PDF_Filename = "Test.pdf" OutPDF = PdfPages( PDF_Filename ) plt.suptitle("Study# : Pos9.img\n{ Acquired : Feb 18, 2003 - $T_o$ @ 14:55:02 }") plt.savefig( OutPDF, dpi=600, format="pdf" ) OutPDF.close() and this also works, the text is now written correctly in Test.pdf. However, if I add a second call to plt.suptitle in the script the text added from the first call is removed, which is what was refered to in the first response. Cheers Peter -- Introducing Performance Central, a new site from SourceForge and AppDynamics. Performance Central is your source for news, insights, analysis and resources for efficient Application Performance Management. Visit us
Re: [Matplotlib-users] Matplotlib V1.3 suptitle
On Fri, Aug 23, 2013 at 11:21 AM, Peter Bloomfield < peter.bloomfi...@camhpet.ca> wrote: > > On 08/23/2013 10:43 AM, Benjamin Root wrote: > > > > On Fri, Aug 23, 2013 at 9:57 AM, Peter Bloomfield < > peter.bloomfi...@camhpet.ca> wrote: > >> Good morning, >> >> I am running openSuSE 12.2, and this morning I upgraded matplotlib to >> v1.3, and now I am having a problem with suptitle. >> I use the following lines to put a title and legend onto a plot figure >> >> import matplotlib.pyplot as plt >> plt.figure(1) >> >> plt.suptitle( "Study# : " + os.path.basename( inImage_IO.IO_FileName ) + \ >> >> "\n" + "{ Acquired : " + \ >> >> AcqDateTime.strftime( "%b %d, %Y - $T_o$ @ %H:%M:%S" ) + " }", \ >> >> y=0.98, weight="roman", size="large" ) >> >> plt.suptitle( "{Creation Date : " + AnalysisTOD + "}", >> >> x=0.86, y=0.03, weight="roman", size="x-small" ) >> >> >> Under v1.3, I only get the 'Creation Date : ...' text at the bottom of >> the figure the 'Study# ...' string is not present at the top. If I change >> it to >> >> import matplotlib.pyplot as plt >> plt.figure(1) >> >> plt.suptitle( "Study# : ", y=0.98, weight="roman", size="large" ) >> >> plt.suptitle( "{Creation Date : " + AnalysisTOD + "}", >> >> x=0.86, y=0.03, weight="roman", size="x-small" ) >> >> the 'Creation Date : ...' text at the bottom of the figure the 'Study# >> : ' string is at the top. >> >> >> So the problem is in the string construct in the first example. Does >> anybody know of a way to get around this? >> >> >> Thanks in advance >> >> >> Peter >> >> > Oh, wow... we didn't think anybody was using that "misfeature". This was > a bug we fixed for 1.3, in that users complained that calling plt.title() > would update an existing title, but plt.suptitle() would not (multiple > calls would just result in text overlaid on top of each other). We fixed > this for 1.3 so that there is a single text object that is kept and is > revised in subsequent calls to suptitle(). To get what you want, you will > have to consolidate those strings into one. > > Cheers! > Ben > >Thanks for getting back to me, but I have tried to do as you suggest, > but to no avail, and here I apologise for my lack of knowledge of > python/matplotlib. > I consolidated the strings into one, titleStr > > titleStr = "Study# : " + os.path.basename( inImage_IO.IO_FileName ) + \ > >"\n" + "{ Acquired : " + \ > AcqDateTime.strftime( "%b %d, %Y - $T_o$ @ %H:%M:%S" ) + " > }" > plt.suptitle( titleStr, y=0.98, weight="roman", size="large" ) > > which should write the string > 'Study# : Pos9.img\n{ Acquired : Feb 18, 2003 - $T_o$ @ 14:55:02 }' > at the top of the figure, but it did not, so I thought it is the "\n", > and tried > > titleStr = "Study# : " + os.path.basename( inImage_IO.IO_FileName ) > plt.suptitle( titleStr, y=0.98, weight="roman", size="large" ) > > which should write the string > 'Study# : Pos9.img' > and this again failed to write the suptitle in the figure. > > Am I being dumb (rhetorical)? What is the best way to consolidate the > strings to work with suptitle, many thanks in advance. > > Cheers > > Peter > > No issues here. Let's try simplifying it further and further. Try the following script. import matplotlib.pyplot as plt plt.suptitle("Study# : Pos9.img") plt.show() Does that work for you? If it does, iterate on that code example, adding pieces back into it and see when it breaks. Ben Root -- Introducing Performance Central, a new site from SourceForge and AppDynamics. Performance Central is your source for news, insights, analysis and resources for efficient Application Performance Management. Visit us today! http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Matplotlib V1.3 suptitle
On 08/23/2013 10:43 AM, Benjamin Root wrote: On Fri, Aug 23, 2013 at 9:57 AM, Peter Bloomfield mailto:peter.bloomfi...@camhpet.ca>> wrote: Good morning, I am running openSuSE 12.2, and this morning I upgraded matplotlib to v1.3, and now I am having a problem with suptitle. I use the following lines to put a title and legend onto a plot figure import matplotlib.pyplot as plt plt.figure(1) plt.suptitle( "Study# : " + os.path.basename( inImage_IO.IO_FileName ) + \ "\n" + "{ Acquired : " + \ AcqDateTime.strftime( "%b %d, %Y - $T_o$ @ %H:%M:%S" ) + " }", \ y=0.98, weight="roman", size="large" ) plt.suptitle( "{Creation Date : " + AnalysisTOD + "}", x=0.86, y=0.03, weight="roman", size="x-small" ) Under v1.3, I only get the 'Creation Date : ...' text at the bottom of the figure the 'Study# ...' string is not present at the top. If I change it to import matplotlib.pyplot as plt plt.figure(1) plt.suptitle( "Study# : ", y=0.98, weight="roman", size="large" ) plt.suptitle( "{Creation Date : " + AnalysisTOD + "}", x=0.86, y=0.03, weight="roman", size="x-small" ) the 'Creation Date : ...' text at the bottom of the figure the 'Study# : ' string is at the top. So the problem is in the string construct in the first example. Does anybody know of a way to get around this? Thanks in advance Peter Oh, wow... we didn't think anybody was using that "misfeature". This was a bug we fixed for 1.3, in that users complained that calling plt.title() would update an existing title, but plt.suptitle() would not (multiple calls would just result in text overlaid on top of each other). We fixed this for 1.3 so that there is a single text object that is kept and is revised in subsequent calls to suptitle(). To get what you want, you will have to consolidate those strings into one. Cheers! Ben Thanks for getting back to me, but I have tried to do as you suggest, but to no avail, and here I apologise for my lack of knowledge of python/matplotlib. I consolidated the strings into one, titleStr titleStr = "Study# : " + os.path.basename( inImage_IO.IO_FileName ) + \ "\n" + "{ Acquired : " + \ AcqDateTime.strftime( "%b %d, %Y - $T_o$ @ %H:%M:%S" ) + " }" plt.suptitle( titleStr, y=0.98, weight="roman", size="large" ) which should write the string 'Study# : Pos9.img\n{ Acquired : Feb 18, 2003 - $T_o$ @ 14:55:02 }' at the top of the figure, but it did not, so I thought it is the "\n", and tried titleStr = "Study# : " + os.path.basename( inImage_IO.IO_FileName ) plt.suptitle( titleStr, y=0.98, weight="roman", size="large" ) which should write the string 'Study# : Pos9.img' and this again failed to write the suptitle in the figure. Am I being dumb (rhetorical)? What is the best way to consolidate the strings to work with suptitle, many thanks in advance. Cheers Peter -- Peter M. Bloomfield Physicist, PET Centre, Centre for Addiction and Mental Health, 250 College St., Toronto, Ontario, Canada M5T 1R8 Tel: 416 535 8501 Ext. 4243 -- Introducing Performance Central, a new site from SourceForge and AppDynamics. Performance Central is your source for news, insights, analysis and resources for efficient Application Performance Management. Visit us today! http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Matplotlib V1.3 suptitle
On Aug 23, 2013, at 7:43AM, Benjamin Root wrote: > > > On Fri, Aug 23, 2013 at 9:57 AM, Peter Bloomfield > wrote: > Good morning, > > I am running openSuSE 12.2, and this morning I upgraded matplotlib to v1.3, > and now I am having a problem with suptitle. > I use the following lines to put a title and legend onto a plot figure > > import matplotlib.pyplot as plt > plt.figure(1) > plt.suptitle( "Study# : " + os.path.basename( inImage_IO.IO_FileName ) + \ > "\n" + "{ Acquired : " + \ > AcqDateTime.strftime( "%b %d, %Y - $T_o$ @ %H:%M:%S" ) + " }", \ > y=0.98, weight="roman", size="large" ) > plt.suptitle( "{Creation Date : " + AnalysisTOD + "}", > x=0.86, y=0.03, weight="roman", size="x-small" ) > > Under v1.3, I only get the 'Creation Date : ...' text at the bottom of the > figure the 'Study# ...' string is not present at the top. If I change > it to > > import matplotlib.pyplot as plt > plt.figure(1) > plt.suptitle( "Study# : ", y=0.98, weight="roman", size="large" ) > plt.suptitle( "{Creation Date : " + AnalysisTOD + "}", > x=0.86, y=0.03, weight="roman", size="x-small" ) > > the 'Creation Date : ...' text at the bottom of the figure the 'Study# : ' > string is at the top. > > So the problem is in the string construct in the first example. Does anybody > know of a way to get around this? > > Thanks in advance > > Peter > > > Oh, wow... we didn't think anybody was using that "misfeature". This was a > bug we fixed for 1.3, in that users complained that calling plt.title() would > update an existing title, but plt.suptitle() would not (multiple calls would > just result in text overlaid on top of each other). We fixed this for 1.3 so > that there is a single text object that is kept and is revised in subsequent > calls to suptitle(). To get what you want, you will have to consolidate > those strings into one. > > Cheers! > Ben Ben, I am glad for the fix. Peter, You could use gcf().text(x,y,'String 1',**keyw) gcf().text(x2,y2,'String 2',**keyw) -Sterling -- Introducing Performance Central, a new site from SourceForge and AppDynamics. Performance Central is your source for news, insights, analysis and resources for efficient Application Performance Management. Visit us today! http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Matplotlib V1.3 suptitle
On Fri, Aug 23, 2013 at 9:57 AM, Peter Bloomfield < peter.bloomfi...@camhpet.ca> wrote: > Good morning, > > I am running openSuSE 12.2, and this morning I upgraded matplotlib to > v1.3, and now I am having a problem with suptitle. > I use the following lines to put a title and legend onto a plot figure > > import matplotlib.pyplot as plt > plt.figure(1) > > plt.suptitle( "Study# : " + os.path.basename( inImage_IO.IO_FileName ) + \ > > "\n" + "{ Acquired : " + \ > > AcqDateTime.strftime( "%b %d, %Y - $T_o$ @ %H:%M:%S" ) + " }", \ > > y=0.98, weight="roman", size="large" ) > > plt.suptitle( "{Creation Date : " + AnalysisTOD + "}", > > x=0.86, y=0.03, weight="roman", size="x-small" ) > > > Under v1.3, I only get the 'Creation Date : ...' text at the bottom of > the figure the 'Study# ...' string is not present at the top. If I change > it to > > import matplotlib.pyplot as plt > plt.figure(1) > > plt.suptitle( "Study# : ", y=0.98, weight="roman", size="large" ) > > plt.suptitle( "{Creation Date : " + AnalysisTOD + "}", > > x=0.86, y=0.03, weight="roman", size="x-small" ) > > the 'Creation Date : ...' text at the bottom of the figure the 'Study# : > ' string is at the top. > > > So the problem is in the string construct in the first example. Does > anybody know of a way to get around this? > > > Thanks in advance > > > Peter > > Oh, wow... we didn't think anybody was using that "misfeature". This was a bug we fixed for 1.3, in that users complained that calling plt.title() would update an existing title, but plt.suptitle() would not (multiple calls would just result in text overlaid on top of each other). We fixed this for 1.3 so that there is a single text object that is kept and is revised in subsequent calls to suptitle(). To get what you want, you will have to consolidate those strings into one. Cheers! Ben -- Introducing Performance Central, a new site from SourceForge and AppDynamics. Performance Central is your source for news, insights, analysis and resources for efficient Application Performance Management. Visit us today! http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users