From a.halder at jacobs-university.de Fri Jul 1 10:23:24 2016 From: a.halder at jacobs-university.de (anikhalder) Date: Fri, 1 Jul 2016 07:23:24 -0700 (MST) Subject: [Matplotlib-users] IPython FITS file plotting problem Message-ID: <1467383004708-47271.post@n5.nabble.com> Dear all, I am facing a problem while running a script ( please find the attached files - I am attaching both the ipython notebook version and also the python script ). I am trying to plot an array of values, write it into a FITS file format, read it back again and plot it ---> I don't get the same plots! I shall be highly obliged if you can kindly help me with this. The following are the versions of my packages and compiler: matplotlib : '2.0.0b1' numpy : '1.11.0' astropy : u'1.1.2' python : 2.7 Sincerely, Anik Halder problem_fits_file.ipynb problem_fits_file.py -- View this message in context: http://matplotlib.1069221.n5.nabble.com/IPython-FITS-file-plotting-problem-tp47271.html Sent from the matplotlib - users mailing list archive at Nabble.com. From jenshnielsen at gmail.com Fri Jul 1 11:21:43 2016 From: jenshnielsen at gmail.com (Jens Nielsen) Date: Fri, 01 Jul 2016 15:21:43 +0000 Subject: [Matplotlib-users] IPython FITS file plotting problem In-Reply-To: <1467383004708-47271.post@n5.nabble.com> References: <1467383004708-47271.post@n5.nabble.com> Message-ID: I can reproduce your issue with matplotlib 2 beta1 but not with 1.51, See https://gist.github.com/jenshnielsen/86d4a86d8f667fadddc09f88c5fb87e6 I think this relates to the dtype of the data (see the last two cells of my notebook) can you open an issue for this at github? It seems like the fits data is converted from float32 to big endian float8. best Jens On Fri, 1 Jul 2016 at 15:23 anikhalder wrote: > Dear all, > > I am facing a problem while running a script ( please find the attached > files - I am attaching both the ipython notebook version and also the > python > script ). > > I am trying to plot an array of values, write it into a FITS file format, > read it back again and plot it ---> I don't get the same plots! > > I shall be highly obliged if you can kindly help me with this. > > The following are the versions of my packages and compiler: > > matplotlib : '2.0.0b1' > > numpy : '1.11.0' > > astropy : u'1.1.2' > > python : 2.7 > > Sincerely, > Anik Halder > > problem_fits_file.ipynb > < > http://matplotlib.1069221.n5.nabble.com/file/n47271/problem_fits_file.ipynb > > > problem_fits_file.py > > > > > -- > View this message in context: > http://matplotlib.1069221.n5.nabble.com/IPython-FITS-file-plotting-problem-tp47271.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jenshnielsen at gmail.com Fri Jul 1 12:03:07 2016 From: jenshnielsen at gmail.com (Jens Nielsen) Date: Fri, 01 Jul 2016 16:03:07 +0000 Subject: [Matplotlib-users] IPython FITS file plotting problem In-Reply-To: <79CA8A516F093142ADC298EF2D98B9F704832279@SXCHMB01.jacobs.jacobs-university.de> References: <1467383004708-47271.post@n5.nabble.com> <79CA8A516F093142ADC298EF2D98B9F704832279@SXCHMB01.jacobs.jacobs-university.de> Message-ID: Sure. The bug report is up at at https://github.com/matplotlib/matplotlib/issues/6671 In the mean time you can either switch to 1.5.x or change the code to plt.imshow(Z_read.astype(' wrote: > Hi Jens, > > Thank you so very much for your help. > > Unfortunately I'm really am not too familiar with github. Will it be > possible for you to open a discussion there and send me the link? > > Will be very obliged if you could do so. > > Thank you once again, > > Anik > ------------------------------ > *From:* Jens Nielsen [jenshnielsen at gmail.com] > *Sent:* Friday, July 01, 2016 5:21 PM > *To:* Halder, Anik; matplotlib-users at python.org > *Subject:* Re: [Matplotlib-users] IPython FITS file plotting problem > > I can reproduce your issue with matplotlib 2 beta1 but not with 1.51, See > https://gist.github.com/jenshnielsen/86d4a86d8f667fadddc09f88c5fb87e6 I > think this relates to the dtype of the data (see the last two cells of my > notebook) can you open an issue for this at github? It seems like the fits > data is converted from float32 to big endian float8. > > best > Jens > > On Fri, 1 Jul 2016 at 15:23 anikhalder > wrote: > >> Dear all, >> >> I am facing a problem while running a script ( please find the attached >> files - I am attaching both the ipython notebook version and also the >> python >> script ). >> >> I am trying to plot an array of values, write it into a FITS file format, >> read it back again and plot it ---> I don't get the same plots! >> >> I shall be highly obliged if you can kindly help me with this. >> >> The following are the versions of my packages and compiler: >> >> matplotlib : '2.0.0b1' >> >> numpy : '1.11.0' >> >> astropy : u'1.1.2' >> >> python : 2.7 >> >> Sincerely, >> Anik Halder >> >> problem_fits_file.ipynb >> < >> http://matplotlib.1069221.n5.nabble.com/file/n47271/problem_fits_file.ipynb >> > >> problem_fits_file.py >> > > >> >> >> >> -- >> View this message in context: >> http://matplotlib.1069221.n5.nabble.com/IPython-FITS-file-plotting-problem-tp47271.html >> Sent from the matplotlib - users mailing list archive at Nabble.com. >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From x.piter at gmail.com Fri Jul 8 04:41:38 2016 From: x.piter at gmail.com (Piter_) Date: Fri, 8 Jul 2016 10:41:38 +0200 Subject: [Matplotlib-users] Image full screen Message-ID: Hi list. I wander if it is possible to show a full screen image using matplotlib? Only image without axis axis, window frame and so on.... ------ from numpy import random import matplotlib.pyplot as plt import matplotlib as mpl mpl.rcParams['toolbar'] = 'None' plt.ion() fig = figure() data = random.random((600,800)) img = plt.imshow(data, interpolation='nearest') img.set_cmap('hot') plt.axis('off') plt.tight_layout() plt.subplots_adjust(left=0, right=1, top=1, bottom=0) figManager = plt.get_current_fig_manager() figManager.window.showMaximized() -------- This part kind of works. There are only two problems. 1 I have to hit f button (full screen) to remove window title, 2 There still a gray part on the bottom, where mouse XY coordinates are usually shown. Any recommendations how to get rid of those? Thank you Petro -------------- next part -------------- An HTML attachment was scrubbed... URL: From jfoxrabinovitz at gmail.com Mon Jul 11 11:12:58 2016 From: jfoxrabinovitz at gmail.com (Joseph Fox-Rabinovitz) Date: Mon, 11 Jul 2016 11:12:58 -0400 Subject: [Matplotlib-users] Fwd: Creating Colored Axis Labels using LaTeX in Interactive Mode In-Reply-To: References: Message-ID: I originally posted to Stack Overflow at http://stackoverflow.com/q/38274681/2988730 (and accidentally to the SourceForge version of this list). I am trying to follow the answer at http://stackoverflow.com/a/38008501/2988730 to an earlier question of mine to create colored and styled legend-like entries. I have the following code: import matplotlib as mpl mpl.use('ps') from matplotlib import pyplot as plt mpl.rc('text', usetex=True) mpl.rc('text.latex', preamble='\\usepackage{color}\n\\usepackage{dashrule}') plt.ion() ax = plt.plot((0, 1), (1, 2))[0].axes ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, 0.0}{\rule[0.5ex]{3cm}{1pt}}') plt.savefig('test.ps') The result is as expected. The labels contain black text with a red line on the Y label and a green line on the X label: http://i.stack.imgur.com/JCiLI.png. However, when I try the exact same set of commands without the `mpl.use('ps')` line (using `'qt4agg'` backend on my system), the figure neither saves corectly nor shows up correctly on screen: import matplotlib as mpl from matplotlib import pyplot as plt mpl.rc('text', usetex=True) mpl.rc('text.latex', preamble='\\usepackage{color}\n\\usepackage{dashrule}') plt.ion() ax = plt.plot((0, 1), (1, 2))[0].axes ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, 0.0}{\rule[0.5ex]{3cm}{1pt}}') plt.savefig('test.png') plt.show() The result of `plt.savefig` (http://i.stack.imgur.com/h2LXn.png) and `plt.show` (http://i.stack.imgur.com/0Ow7c.png) are basically the same in this case. The lines after the text show up black. How do I get the colors to show up in the labels with the default interactive backend? Regards, -Joe From jfoxrabinovitz at gmail.com Mon Jul 11 12:05:12 2016 From: jfoxrabinovitz at gmail.com (Joseph Fox-Rabinovitz) Date: Mon, 11 Jul 2016 12:05:12 -0400 Subject: [Matplotlib-users] Creating Colored Axis Labels using LaTeX in Interactive Mode In-Reply-To: References: Message-ID: Have an update on my previous question. I have tried to follow the instructions at http://matplotlib.org/users/pgf.html for settting up the PGF backend for PNG and PDF rendering. This method does not work either: import matplotlib as mpl from matplotlib.backends.backend_pgf import FigureCanvasPgf matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) from matplotlib import pyplot as plt matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) preamble.append(r'\usepackage{color}') # Text config matplotlib.rc('text', usetex=True) preamble = matplotlib.rcParams.setdefault('text.latex.preamble', []) preamble.append(r'\usepackage{color}') ax = plt.plot((0, 1), (1, 2))[0].axes ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, 0.0}{\rule[0.5ex]{3cm}{1pt}}') plt.savefig('test.png') Yields the exact same figure and PNG file with the incorrect black lines as above. Note that turning off the three lines under `# Text config` makes the TeX commands print out verbatim, even in the saved figure. Perhaps there is a way to render the PNG correctly without pre-clobbering with the text system? Regards, -Joe On Mon, Jul 11, 2016 at 11:12 AM, Joseph Fox-Rabinovitz wrote: > I originally posted to Stack Overflow at > http://stackoverflow.com/q/38274681/2988730 (and accidentally to the > SourceForge version of this list). > > I am trying to follow the answer at > http://stackoverflow.com/a/38008501/2988730 to an earlier question of > mine to create colored and styled legend-like entries. I have the > following code: > > import matplotlib as mpl > mpl.use('ps') > from matplotlib import pyplot as plt > > mpl.rc('text', usetex=True) > mpl.rc('text.latex', preamble='\\usepackage{color}\n\\usepackage{dashrule}') > > plt.ion() > ax = plt.plot((0, 1), (1, 2))[0].axes > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > plt.savefig('test.ps') > > The result is as expected. The labels contain black text with a red > line on the Y label and a green line on the X label: > http://i.stack.imgur.com/JCiLI.png. > > However, when I try the exact same set of commands without the > `mpl.use('ps')` line (using `'qt4agg'` backend on my system), the > figure neither saves corectly nor shows up correctly on screen: > > import matplotlib as mpl > from matplotlib import pyplot as plt > > mpl.rc('text', usetex=True) > mpl.rc('text.latex', preamble='\\usepackage{color}\n\\usepackage{dashrule}') > > plt.ion() > ax = plt.plot((0, 1), (1, 2))[0].axes > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > > plt.savefig('test.png') > plt.show() > > The result of `plt.savefig` (http://i.stack.imgur.com/h2LXn.png) and > `plt.show` (http://i.stack.imgur.com/0Ow7c.png) are basically the same > in this case. The lines after the text show up black. > > How do I get the colors to show up in the labels with the default > interactive backend? > > Regards, > > -Joe From jenshnielsen at gmail.com Mon Jul 11 12:35:53 2016 From: jenshnielsen at gmail.com (Jens Nielsen) Date: Mon, 11 Jul 2016 16:35:53 +0000 Subject: [Matplotlib-users] Creating Colored Axis Labels using LaTeX in Interactive Mode In-Reply-To: References: Message-ID: I can confirm that this does not work as expected but I don't know exactly why. With regards to your pgf example. It seems to be missing a \usepackage{ dashrule} The following runs for me but still generates the black non colored bars. The # Text config seems to do nothing in my test so I'm not sure why you need to set it. If I save the pgf backend to a .pgf file and include it in a texfile as below everything looks correct in that example test.py ``` import matplotlib from matplotlib.backends.backend_pgf import FigureCanvasPgf matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) from matplotlib import pyplot as plt matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) preamble.append(r'\usepackage{color}') preamble.append(r'\usepackage{dashrule}') # Text config #matplotlib.rc('text', usetex=True) # preamble = matplotlib.rcParams.setdefault('text.latex.preamble', []) #preamble.append(r'\usepackage{color}') #preamble.append(r'\usepackage{dashrule}') ax = plt.plot((0, 1), (1, 2))[0].axes ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, 0.0}{\rule[0.5ex]{3cm}{1pt}}') plt.savefig('test.pgf') plt.savefig('test.png') ``` test.tex ``` \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{color} \usepackage{dashrule} \usepackage{pgf} \begin{document} \input{test.pgf} \end{document} ``` and running pdflatex test.tex generates a test.pdf that looks as expected. best Jens On Mon, 11 Jul 2016 at 17:08 Joseph Fox-Rabinovitz wrote: > Have an update on my previous question. I have tried to follow the > instructions at http://matplotlib.org/users/pgf.html for settting up > the PGF backend for PNG and PDF rendering. This method does not work > either: > > import matplotlib as mpl > from matplotlib.backends.backend_pgf import FigureCanvasPgf > matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) > from matplotlib import pyplot as plt > > matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v > preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) > preamble.append(r'\usepackage{color}') > > # Text config > matplotlib.rc('text', usetex=True) > preamble = matplotlib.rcParams.setdefault('text.latex.preamble', []) > preamble.append(r'\usepackage{color}') > > ax = plt.plot((0, 1), (1, 2))[0].axes > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > plt.savefig('test.png') > > Yields the exact same figure and PNG file with the incorrect black > lines as above. Note that turning off the three lines under `# Text > config` makes the TeX commands print out verbatim, even in the saved > figure. Perhaps there is a way to render the PNG correctly without > pre-clobbering with the text system? > > Regards, > > -Joe > > > > On Mon, Jul 11, 2016 at 11:12 AM, Joseph Fox-Rabinovitz > wrote: > > I originally posted to Stack Overflow at > > http://stackoverflow.com/q/38274681/2988730 (and accidentally to the > > SourceForge version of this list). > > > > I am trying to follow the answer at > > http://stackoverflow.com/a/38008501/2988730 to an earlier question of > > mine to create colored and styled legend-like entries. I have the > > following code: > > > > import matplotlib as mpl > > mpl.use('ps') > > from matplotlib import pyplot as plt > > > > mpl.rc('text', usetex=True) > > mpl.rc('text.latex', > preamble='\\usepackage{color}\n\\usepackage{dashrule}') > > > > plt.ion() > > ax = plt.plot((0, 1), (1, 2))[0].axes > > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > > plt.savefig('test.ps') > > > > The result is as expected. The labels contain black text with a red > > line on the Y label and a green line on the X label: > > http://i.stack.imgur.com/JCiLI.png. > > > > However, when I try the exact same set of commands without the > > `mpl.use('ps')` line (using `'qt4agg'` backend on my system), the > > figure neither saves corectly nor shows up correctly on screen: > > > > import matplotlib as mpl > > from matplotlib import pyplot as plt > > > > mpl.rc('text', usetex=True) > > mpl.rc('text.latex', > preamble='\\usepackage{color}\n\\usepackage{dashrule}') > > > > plt.ion() > > ax = plt.plot((0, 1), (1, 2))[0].axes > > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > > > > plt.savefig('test.png') > > plt.show() > > > > The result of `plt.savefig` (http://i.stack.imgur.com/h2LXn.png) and > > `plt.show` (http://i.stack.imgur.com/0Ow7c.png) are basically the same > > in this case. The lines after the text show up black. > > > > How do I get the colors to show up in the labels with the default > > interactive backend? > > > > Regards, > > > > -Joe > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jfoxrabinovitz at gmail.com Mon Jul 11 13:49:28 2016 From: jfoxrabinovitz at gmail.com (Joseph Fox-Rabinovitz) Date: Mon, 11 Jul 2016 13:49:28 -0400 Subject: [Matplotlib-users] Creating Colored Axis Labels using LaTeX in Interactive Mode In-Reply-To: References: Message-ID: Thanks for the catch with `\usepackage{dashrule}`. Using matplotlib 1.5, the code you posted does not work as expected. The labels are the literal strings containing LaTeX commands, not the LaTeX output. Adding in the commands under `# Text config` fixed at least that part of the issue. It seems to be caused by the fact that I am using a non-pgf backend by default. Regards, -Joe On Mon, Jul 11, 2016 at 12:35 PM, Jens Nielsen wrote: > I can confirm that this does not work as expected but I don't know exactly > why. > > With regards to your pgf example. It seems to be missing a > \usepackage{dashrule} > > The following runs for me but still generates the black non colored bars. > The # Text config seems to do nothing in my test so I'm not sure why you > need to set it. > > If I save the pgf backend to a .pgf file and include it in a texfile as > below everything looks correct in that example > > test.py > ``` > import matplotlib > from matplotlib.backends.backend_pgf import FigureCanvasPgf > matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) > from matplotlib import pyplot as plt > > matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v > preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) > preamble.append(r'\usepackage{color}') > preamble.append(r'\usepackage{dashrule}') > > # Text config > #matplotlib.rc('text', usetex=True) > # preamble = matplotlib.rcParams.setdefault('text.latex.preamble', []) > #preamble.append(r'\usepackage{color}') > #preamble.append(r'\usepackage{dashrule}') > > ax = plt.plot((0, 1), (1, 2))[0].axes > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > plt.savefig('test.pgf') > plt.savefig('test.png') > ``` > > test.tex > ``` > \documentclass{article} > > \usepackage[utf8]{inputenc} > \usepackage[english]{babel} > > \usepackage{color} > \usepackage{dashrule} > \usepackage{pgf} > > \begin{document} > > \input{test.pgf} > \end{document} > ``` > > and running pdflatex test.tex generates a test.pdf that looks as expected. > > best > Jens > > > > On Mon, 11 Jul 2016 at 17:08 Joseph Fox-Rabinovitz > wrote: >> >> Have an update on my previous question. I have tried to follow the >> instructions at http://matplotlib.org/users/pgf.html for settting up >> the PGF backend for PNG and PDF rendering. This method does not work >> either: >> >> import matplotlib as mpl >> from matplotlib.backends.backend_pgf import FigureCanvasPgf >> matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) >> from matplotlib import pyplot as plt >> >> matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v >> preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) >> preamble.append(r'\usepackage{color}') >> >> # Text config >> matplotlib.rc('text', usetex=True) >> preamble = matplotlib.rcParams.setdefault('text.latex.preamble', []) >> preamble.append(r'\usepackage{color}') >> >> ax = plt.plot((0, 1), (1, 2))[0].axes >> ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, >> 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') >> ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, >> 0.0}{\rule[0.5ex]{3cm}{1pt}}') >> plt.savefig('test.png') >> >> Yields the exact same figure and PNG file with the incorrect black >> lines as above. Note that turning off the three lines under `# Text >> config` makes the TeX commands print out verbatim, even in the saved >> figure. Perhaps there is a way to render the PNG correctly without >> pre-clobbering with the text system? >> >> Regards, >> >> -Joe >> >> >> >> On Mon, Jul 11, 2016 at 11:12 AM, Joseph Fox-Rabinovitz >> wrote: >> > I originally posted to Stack Overflow at >> > http://stackoverflow.com/q/38274681/2988730 (and accidentally to the >> > SourceForge version of this list). >> > >> > I am trying to follow the answer at >> > http://stackoverflow.com/a/38008501/2988730 to an earlier question of >> > mine to create colored and styled legend-like entries. I have the >> > following code: >> > >> > import matplotlib as mpl >> > mpl.use('ps') >> > from matplotlib import pyplot as plt >> > >> > mpl.rc('text', usetex=True) >> > mpl.rc('text.latex', >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') >> > >> > plt.ion() >> > ax = plt.plot((0, 1), (1, 2))[0].axes >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') >> > plt.savefig('test.ps') >> > >> > The result is as expected. The labels contain black text with a red >> > line on the Y label and a green line on the X label: >> > http://i.stack.imgur.com/JCiLI.png. >> > >> > However, when I try the exact same set of commands without the >> > `mpl.use('ps')` line (using `'qt4agg'` backend on my system), the >> > figure neither saves corectly nor shows up correctly on screen: >> > >> > import matplotlib as mpl >> > from matplotlib import pyplot as plt >> > >> > mpl.rc('text', usetex=True) >> > mpl.rc('text.latex', >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') >> > >> > plt.ion() >> > ax = plt.plot((0, 1), (1, 2))[0].axes >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') >> > >> > plt.savefig('test.png') >> > plt.show() >> > >> > The result of `plt.savefig` (http://i.stack.imgur.com/h2LXn.png) and >> > `plt.show` (http://i.stack.imgur.com/0Ow7c.png) are basically the same >> > in this case. The lines after the text show up black. >> > >> > How do I get the colors to show up in the labels with the default >> > interactive backend? >> > >> > Regards, >> > >> > -Joe >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users From jenshnielsen at gmail.com Mon Jul 11 14:55:46 2016 From: jenshnielsen at gmail.com (Jens Nielsen) Date: Mon, 11 Jul 2016 18:55:46 +0000 Subject: [Matplotlib-users] Creating Colored Axis Labels using LaTeX in Interactive Mode In-Reply-To: References: Message-ID: You are right. I suspect that the register_backend logic does not work correctly for png. The code produces the expected results in pdf with register_backend and in both pdf and png if I do matplotlib.use('pgf') so it would seem like there are at least 2 different bugs. The color does not work with the regular latex text backend. register_backend does not work correctly with png and the pgf backend. best Jens On Mon, 11 Jul 2016 at 18:49 Joseph Fox-Rabinovitz wrote: > Thanks for the catch with `\usepackage{dashrule}`. Using matplotlib > 1.5, the code you posted does not work as expected. The labels are the > literal strings containing LaTeX commands, not the LaTeX output. > Adding in the commands under `# Text config` fixed at least that part > of the issue. It seems to be caused by the fact that I am using a > non-pgf backend by default. > > Regards, > > -Joe > > > > On Mon, Jul 11, 2016 at 12:35 PM, Jens Nielsen > wrote: > > I can confirm that this does not work as expected but I don't know > exactly > > why. > > > > With regards to your pgf example. It seems to be missing a > > \usepackage{dashrule} > > > > The following runs for me but still generates the black non colored bars. > > The # Text config seems to do nothing in my test so I'm not sure why you > > need to set it. > > > > If I save the pgf backend to a .pgf file and include it in a texfile as > > below everything looks correct in that example > > > > test.py > > ``` > > import matplotlib > > from matplotlib.backends.backend_pgf import FigureCanvasPgf > > matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) > > from matplotlib import pyplot as plt > > > > matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v > > preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) > > preamble.append(r'\usepackage{color}') > > preamble.append(r'\usepackage{dashrule}') > > > > # Text config > > #matplotlib.rc('text', usetex=True) > > # preamble = matplotlib.rcParams.setdefault('text.latex.preamble', []) > > #preamble.append(r'\usepackage{color}') > > #preamble.append(r'\usepackage{dashrule}') > > > > ax = plt.plot((0, 1), (1, 2))[0].axes > > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > > plt.savefig('test.pgf') > > plt.savefig('test.png') > > ``` > > > > test.tex > > ``` > > \documentclass{article} > > > > \usepackage[utf8]{inputenc} > > \usepackage[english]{babel} > > > > \usepackage{color} > > \usepackage{dashrule} > > \usepackage{pgf} > > > > \begin{document} > > > > \input{test.pgf} > > \end{document} > > ``` > > > > and running pdflatex test.tex generates a test.pdf that looks as > expected. > > > > best > > Jens > > > > > > > > On Mon, 11 Jul 2016 at 17:08 Joseph Fox-Rabinovitz > > wrote: > >> > >> Have an update on my previous question. I have tried to follow the > >> instructions at http://matplotlib.org/users/pgf.html for settting up > >> the PGF backend for PNG and PDF rendering. This method does not work > >> either: > >> > >> import matplotlib as mpl > >> from matplotlib.backends.backend_pgf import FigureCanvasPgf > >> matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) > >> from matplotlib import pyplot as plt > >> > >> matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v > >> preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) > >> preamble.append(r'\usepackage{color}') > >> > >> # Text config > >> matplotlib.rc('text', usetex=True) > >> preamble = matplotlib.rcParams.setdefault('text.latex.preamble', []) > >> preamble.append(r'\usepackage{color}') > >> > >> ax = plt.plot((0, 1), (1, 2))[0].axes > >> ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > >> 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > >> ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > >> 0.0}{\rule[0.5ex]{3cm}{1pt}}') > >> plt.savefig('test.png') > >> > >> Yields the exact same figure and PNG file with the incorrect black > >> lines as above. Note that turning off the three lines under `# Text > >> config` makes the TeX commands print out verbatim, even in the saved > >> figure. Perhaps there is a way to render the PNG correctly without > >> pre-clobbering with the text system? > >> > >> Regards, > >> > >> -Joe > >> > >> > >> > >> On Mon, Jul 11, 2016 at 11:12 AM, Joseph Fox-Rabinovitz > >> wrote: > >> > I originally posted to Stack Overflow at > >> > http://stackoverflow.com/q/38274681/2988730 (and accidentally to the > >> > SourceForge version of this list). > >> > > >> > I am trying to follow the answer at > >> > http://stackoverflow.com/a/38008501/2988730 to an earlier question of > >> > mine to create colored and styled legend-like entries. I have the > >> > following code: > >> > > >> > import matplotlib as mpl > >> > mpl.use('ps') > >> > from matplotlib import pyplot as plt > >> > > >> > mpl.rc('text', usetex=True) > >> > mpl.rc('text.latex', > >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') > >> > > >> > plt.ion() > >> > ax = plt.plot((0, 1), (1, 2))[0].axes > >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > >> > plt.savefig('test.ps') > >> > > >> > The result is as expected. The labels contain black text with a red > >> > line on the Y label and a green line on the X label: > >> > http://i.stack.imgur.com/JCiLI.png. > >> > > >> > However, when I try the exact same set of commands without the > >> > `mpl.use('ps')` line (using `'qt4agg'` backend on my system), the > >> > figure neither saves corectly nor shows up correctly on screen: > >> > > >> > import matplotlib as mpl > >> > from matplotlib import pyplot as plt > >> > > >> > mpl.rc('text', usetex=True) > >> > mpl.rc('text.latex', > >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') > >> > > >> > plt.ion() > >> > ax = plt.plot((0, 1), (1, 2))[0].axes > >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > >> > > >> > plt.savefig('test.png') > >> > plt.show() > >> > > >> > The result of `plt.savefig` (http://i.stack.imgur.com/h2LXn.png) and > >> > `plt.show` (http://i.stack.imgur.com/0Ow7c.png) are basically the > same > >> > in this case. The lines after the text show up black. > >> > > >> > How do I get the colors to show up in the labels with the default > >> > interactive backend? > >> > > >> > Regards, > >> > > >> > -Joe > >> _______________________________________________ > >> Matplotlib-users mailing list > >> Matplotlib-users at python.org > >> https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jfoxrabinovitz at gmail.com Mon Jul 11 15:06:52 2016 From: jfoxrabinovitz at gmail.com (Joseph Fox-Rabinovitz) Date: Mon, 11 Jul 2016 15:06:52 -0400 Subject: [Matplotlib-users] Creating Colored Axis Labels using LaTeX in Interactive Mode In-Reply-To: References: Message-ID: It seems that for the time being, `use('ps')` is the only way to get the rendering done correctly. I was hoping to get something that rendered with partial accuracy in interactive mode while allowing me to save correctly to a file. Any objections to me filing an issue about this? Regards, -Joe On Mon, Jul 11, 2016 at 2:55 PM, Jens Nielsen wrote: > You are right. I suspect that the register_backend logic does not work > correctly for png. The code produces the expected results > in pdf with register_backend and in both pdf and png if I do > matplotlib.use('pgf') so it would seem like there are at least 2 different > bugs. > > The color does not work with the regular latex text backend. > > register_backend does not work correctly with png and the pgf backend. > > best > Jens > > > > > On Mon, 11 Jul 2016 at 18:49 Joseph Fox-Rabinovitz > wrote: >> >> Thanks for the catch with `\usepackage{dashrule}`. Using matplotlib >> 1.5, the code you posted does not work as expected. The labels are the >> literal strings containing LaTeX commands, not the LaTeX output. >> Adding in the commands under `# Text config` fixed at least that part >> of the issue. It seems to be caused by the fact that I am using a >> non-pgf backend by default. >> >> Regards, >> >> -Joe >> >> >> >> On Mon, Jul 11, 2016 at 12:35 PM, Jens Nielsen >> wrote: >> > I can confirm that this does not work as expected but I don't know >> > exactly >> > why. >> > >> > With regards to your pgf example. It seems to be missing a >> > \usepackage{dashrule} >> > >> > The following runs for me but still generates the black non colored >> > bars. >> > The # Text config seems to do nothing in my test so I'm not sure why you >> > need to set it. >> > >> > If I save the pgf backend to a .pgf file and include it in a texfile as >> > below everything looks correct in that example >> > >> > test.py >> > ``` >> > import matplotlib >> > from matplotlib.backends.backend_pgf import FigureCanvasPgf >> > matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) >> > from matplotlib import pyplot as plt >> > >> > matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v >> > preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) >> > preamble.append(r'\usepackage{color}') >> > preamble.append(r'\usepackage{dashrule}') >> > >> > # Text config >> > #matplotlib.rc('text', usetex=True) >> > # preamble = matplotlib.rcParams.setdefault('text.latex.preamble', []) >> > #preamble.append(r'\usepackage{color}') >> > #preamble.append(r'\usepackage{dashrule}') >> > >> > ax = plt.plot((0, 1), (1, 2))[0].axes >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') >> > plt.savefig('test.pgf') >> > plt.savefig('test.png') >> > ``` >> > >> > test.tex >> > ``` >> > \documentclass{article} >> > >> > \usepackage[utf8]{inputenc} >> > \usepackage[english]{babel} >> > >> > \usepackage{color} >> > \usepackage{dashrule} >> > \usepackage{pgf} >> > >> > \begin{document} >> > >> > \input{test.pgf} >> > \end{document} >> > ``` >> > >> > and running pdflatex test.tex generates a test.pdf that looks as >> > expected. >> > >> > best >> > Jens >> > >> > >> > >> > On Mon, 11 Jul 2016 at 17:08 Joseph Fox-Rabinovitz >> > wrote: >> >> >> >> Have an update on my previous question. I have tried to follow the >> >> instructions at http://matplotlib.org/users/pgf.html for settting up >> >> the PGF backend for PNG and PDF rendering. This method does not work >> >> either: >> >> >> >> import matplotlib as mpl >> >> from matplotlib.backends.backend_pgf import FigureCanvasPgf >> >> matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) >> >> from matplotlib import pyplot as plt >> >> >> >> matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v >> >> preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) >> >> preamble.append(r'\usepackage{color}') >> >> >> >> # Text config >> >> matplotlib.rc('text', usetex=True) >> >> preamble = matplotlib.rcParams.setdefault('text.latex.preamble', >> >> []) >> >> preamble.append(r'\usepackage{color}') >> >> >> >> ax = plt.plot((0, 1), (1, 2))[0].axes >> >> ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, >> >> 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') >> >> ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, >> >> 0.0}{\rule[0.5ex]{3cm}{1pt}}') >> >> plt.savefig('test.png') >> >> >> >> Yields the exact same figure and PNG file with the incorrect black >> >> lines as above. Note that turning off the three lines under `# Text >> >> config` makes the TeX commands print out verbatim, even in the saved >> >> figure. Perhaps there is a way to render the PNG correctly without >> >> pre-clobbering with the text system? >> >> >> >> Regards, >> >> >> >> -Joe >> >> >> >> >> >> >> >> On Mon, Jul 11, 2016 at 11:12 AM, Joseph Fox-Rabinovitz >> >> wrote: >> >> > I originally posted to Stack Overflow at >> >> > http://stackoverflow.com/q/38274681/2988730 (and accidentally to the >> >> > SourceForge version of this list). >> >> > >> >> > I am trying to follow the answer at >> >> > http://stackoverflow.com/a/38008501/2988730 to an earlier question of >> >> > mine to create colored and styled legend-like entries. I have the >> >> > following code: >> >> > >> >> > import matplotlib as mpl >> >> > mpl.use('ps') >> >> > from matplotlib import pyplot as plt >> >> > >> >> > mpl.rc('text', usetex=True) >> >> > mpl.rc('text.latex', >> >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') >> >> > >> >> > plt.ion() >> >> > ax = plt.plot((0, 1), (1, 2))[0].axes >> >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, >> >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') >> >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, >> >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') >> >> > plt.savefig('test.ps') >> >> > >> >> > The result is as expected. The labels contain black text with a red >> >> > line on the Y label and a green line on the X label: >> >> > http://i.stack.imgur.com/JCiLI.png. >> >> > >> >> > However, when I try the exact same set of commands without the >> >> > `mpl.use('ps')` line (using `'qt4agg'` backend on my system), the >> >> > figure neither saves corectly nor shows up correctly on screen: >> >> > >> >> > import matplotlib as mpl >> >> > from matplotlib import pyplot as plt >> >> > >> >> > mpl.rc('text', usetex=True) >> >> > mpl.rc('text.latex', >> >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') >> >> > >> >> > plt.ion() >> >> > ax = plt.plot((0, 1), (1, 2))[0].axes >> >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, >> >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') >> >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, >> >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') >> >> > >> >> > plt.savefig('test.png') >> >> > plt.show() >> >> > >> >> > The result of `plt.savefig` (http://i.stack.imgur.com/h2LXn.png) and >> >> > `plt.show` (http://i.stack.imgur.com/0Ow7c.png) are basically the >> >> > same >> >> > in this case. The lines after the text show up black. >> >> > >> >> > How do I get the colors to show up in the labels with the default >> >> > interactive backend? >> >> > >> >> > Regards, >> >> > >> >> > -Joe >> >> _______________________________________________ >> >> Matplotlib-users mailing list >> >> Matplotlib-users at python.org >> >> https://mail.python.org/mailman/listinfo/matplotlib-users From jenshnielsen at gmail.com Mon Jul 11 15:19:20 2016 From: jenshnielsen at gmail.com (Jens Nielsen) Date: Mon, 11 Jul 2016 19:19:20 +0000 Subject: [Matplotlib-users] Creating Colored Axis Labels using LaTeX in Interactive Mode In-Reply-To: References: Message-ID: Well pdf from the PGF backend also work as you expect for me Feel free to open a ticket but note that the latex preample is not officially supported. I suspect that the reason setting the color doesn't work is that the matplotlib default color handling overwrites it as in this example http://matplotlib.org/users/usetex.html#usetex-with-unicode that is however not as easy if you only want to partially color the text On Mon, 11 Jul 2016 at 20:06 Joseph Fox-Rabinovitz wrote: > It seems that for the time being, `use('ps')` is the only way to get > the rendering done correctly. I was hoping to get something that > rendered with partial accuracy in interactive mode while allowing me > to save correctly to a file. Any objections to me filing an issue > about this? > > Regards, > > -Joe > > > On Mon, Jul 11, 2016 at 2:55 PM, Jens Nielsen > wrote: > > You are right. I suspect that the register_backend logic does not work > > correctly for png. The code produces the expected results > > in pdf with register_backend and in both pdf and png if I do > > matplotlib.use('pgf') so it would seem like there are at least 2 > different > > bugs. > > > > The color does not work with the regular latex text backend. > > > > register_backend does not work correctly with png and the pgf backend. > > > > best > > Jens > > > > > > > > > > On Mon, 11 Jul 2016 at 18:49 Joseph Fox-Rabinovitz > > wrote: > >> > >> Thanks for the catch with `\usepackage{dashrule}`. Using matplotlib > >> 1.5, the code you posted does not work as expected. The labels are the > >> literal strings containing LaTeX commands, not the LaTeX output. > >> Adding in the commands under `# Text config` fixed at least that part > >> of the issue. It seems to be caused by the fact that I am using a > >> non-pgf backend by default. > >> > >> Regards, > >> > >> -Joe > >> > >> > >> > >> On Mon, Jul 11, 2016 at 12:35 PM, Jens Nielsen > >> wrote: > >> > I can confirm that this does not work as expected but I don't know > >> > exactly > >> > why. > >> > > >> > With regards to your pgf example. It seems to be missing a > >> > \usepackage{dashrule} > >> > > >> > The following runs for me but still generates the black non colored > >> > bars. > >> > The # Text config seems to do nothing in my test so I'm not sure why > you > >> > need to set it. > >> > > >> > If I save the pgf backend to a .pgf file and include it in a texfile > as > >> > below everything looks correct in that example > >> > > >> > test.py > >> > ``` > >> > import matplotlib > >> > from matplotlib.backends.backend_pgf import FigureCanvasPgf > >> > matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) > >> > from matplotlib import pyplot as plt > >> > > >> > matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v > >> > preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) > >> > preamble.append(r'\usepackage{color}') > >> > preamble.append(r'\usepackage{dashrule}') > >> > > >> > # Text config > >> > #matplotlib.rc('text', usetex=True) > >> > # preamble = matplotlib.rcParams.setdefault('text.latex.preamble', []) > >> > #preamble.append(r'\usepackage{color}') > >> > #preamble.append(r'\usepackage{dashrule}') > >> > > >> > ax = plt.plot((0, 1), (1, 2))[0].axes > >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > >> > plt.savefig('test.pgf') > >> > plt.savefig('test.png') > >> > ``` > >> > > >> > test.tex > >> > ``` > >> > \documentclass{article} > >> > > >> > \usepackage[utf8]{inputenc} > >> > \usepackage[english]{babel} > >> > > >> > \usepackage{color} > >> > \usepackage{dashrule} > >> > \usepackage{pgf} > >> > > >> > \begin{document} > >> > > >> > \input{test.pgf} > >> > \end{document} > >> > ``` > >> > > >> > and running pdflatex test.tex generates a test.pdf that looks as > >> > expected. > >> > > >> > best > >> > Jens > >> > > >> > > >> > > >> > On Mon, 11 Jul 2016 at 17:08 Joseph Fox-Rabinovitz > >> > wrote: > >> >> > >> >> Have an update on my previous question. I have tried to follow the > >> >> instructions at http://matplotlib.org/users/pgf.html for settting up > >> >> the PGF backend for PNG and PDF rendering. This method does not work > >> >> either: > >> >> > >> >> import matplotlib as mpl > >> >> from matplotlib.backends.backend_pgf import FigureCanvasPgf > >> >> matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) > >> >> from matplotlib import pyplot as plt > >> >> > >> >> matplotlib.rc('pgf', texsystem='pdflatex') # from running latex > -v > >> >> preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) > >> >> preamble.append(r'\usepackage{color}') > >> >> > >> >> # Text config > >> >> matplotlib.rc('text', usetex=True) > >> >> preamble = matplotlib.rcParams.setdefault('text.latex.preamble', > >> >> []) > >> >> preamble.append(r'\usepackage{color}') > >> >> > >> >> ax = plt.plot((0, 1), (1, 2))[0].axes > >> >> ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > >> >> 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > >> >> ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > >> >> 0.0}{\rule[0.5ex]{3cm}{1pt}}') > >> >> plt.savefig('test.png') > >> >> > >> >> Yields the exact same figure and PNG file with the incorrect black > >> >> lines as above. Note that turning off the three lines under `# Text > >> >> config` makes the TeX commands print out verbatim, even in the saved > >> >> figure. Perhaps there is a way to render the PNG correctly without > >> >> pre-clobbering with the text system? > >> >> > >> >> Regards, > >> >> > >> >> -Joe > >> >> > >> >> > >> >> > >> >> On Mon, Jul 11, 2016 at 11:12 AM, Joseph Fox-Rabinovitz > >> >> wrote: > >> >> > I originally posted to Stack Overflow at > >> >> > http://stackoverflow.com/q/38274681/2988730 (and accidentally to > the > >> >> > SourceForge version of this list). > >> >> > > >> >> > I am trying to follow the answer at > >> >> > http://stackoverflow.com/a/38008501/2988730 to an earlier > question of > >> >> > mine to create colored and styled legend-like entries. I have the > >> >> > following code: > >> >> > > >> >> > import matplotlib as mpl > >> >> > mpl.use('ps') > >> >> > from matplotlib import pyplot as plt > >> >> > > >> >> > mpl.rc('text', usetex=True) > >> >> > mpl.rc('text.latex', > >> >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') > >> >> > > >> >> > plt.ion() > >> >> > ax = plt.plot((0, 1), (1, 2))[0].axes > >> >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > >> >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > >> >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > >> >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > >> >> > plt.savefig('test.ps') > >> >> > > >> >> > The result is as expected. The labels contain black text with a red > >> >> > line on the Y label and a green line on the X label: > >> >> > http://i.stack.imgur.com/JCiLI.png. > >> >> > > >> >> > However, when I try the exact same set of commands without the > >> >> > `mpl.use('ps')` line (using `'qt4agg'` backend on my system), the > >> >> > figure neither saves corectly nor shows up correctly on screen: > >> >> > > >> >> > import matplotlib as mpl > >> >> > from matplotlib import pyplot as plt > >> >> > > >> >> > mpl.rc('text', usetex=True) > >> >> > mpl.rc('text.latex', > >> >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') > >> >> > > >> >> > plt.ion() > >> >> > ax = plt.plot((0, 1), (1, 2))[0].axes > >> >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > >> >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > >> >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > >> >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > >> >> > > >> >> > plt.savefig('test.png') > >> >> > plt.show() > >> >> > > >> >> > The result of `plt.savefig` (http://i.stack.imgur.com/h2LXn.png) > and > >> >> > `plt.show` (http://i.stack.imgur.com/0Ow7c.png) are basically the > >> >> > same > >> >> > in this case. The lines after the text show up black. > >> >> > > >> >> > How do I get the colors to show up in the labels with the default > >> >> > interactive backend? > >> >> > > >> >> > Regards, > >> >> > > >> >> > -Joe > >> >> _______________________________________________ > >> >> Matplotlib-users mailing list > >> >> Matplotlib-users at python.org > >> >> https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jfoxrabinovitz at gmail.com Mon Jul 11 15:37:55 2016 From: jfoxrabinovitz at gmail.com (Joseph Fox-Rabinovitz) Date: Mon, 11 Jul 2016 15:37:55 -0400 Subject: [Matplotlib-users] Creating Colored Axis Labels using LaTeX in Interactive Mode In-Reply-To: References: Message-ID: I will put in a ticket shortly. I noticed that text latex preamble is not supported according to the docs, but there is nothing about pgf latex preamble. Perhaps the docs need to be updated there as well? Either way, I don't think the issue is with the preamble at all, since that seems to be importing the requested packages as expected. I think the unicode link you posted has bearing on the issue, but I have not experimented enough yet to know exactly how. Thanks, -Joe On Mon, Jul 11, 2016 at 3:19 PM, Jens Nielsen wrote: > Well pdf from the PGF backend also work as you expect for me > > Feel free to open a ticket but note that the latex preample is not > officially supported. > > I suspect that the reason setting the color doesn't work is that the > matplotlib default color handling overwrites it > as in this example > http://matplotlib.org/users/usetex.html#usetex-with-unicode that is however > not as easy if you only want to partially color the text > > > > > On Mon, 11 Jul 2016 at 20:06 Joseph Fox-Rabinovitz > wrote: >> >> It seems that for the time being, `use('ps')` is the only way to get >> the rendering done correctly. I was hoping to get something that >> rendered with partial accuracy in interactive mode while allowing me >> to save correctly to a file. Any objections to me filing an issue >> about this? >> >> Regards, >> >> -Joe >> >> >> On Mon, Jul 11, 2016 at 2:55 PM, Jens Nielsen >> wrote: >> > You are right. I suspect that the register_backend logic does not work >> > correctly for png. The code produces the expected results >> > in pdf with register_backend and in both pdf and png if I do >> > matplotlib.use('pgf') so it would seem like there are at least 2 >> > different >> > bugs. >> > >> > The color does not work with the regular latex text backend. >> > >> > register_backend does not work correctly with png and the pgf backend. >> > >> > best >> > Jens >> > >> > >> > >> > >> > On Mon, 11 Jul 2016 at 18:49 Joseph Fox-Rabinovitz >> > wrote: >> >> >> >> Thanks for the catch with `\usepackage{dashrule}`. Using matplotlib >> >> 1.5, the code you posted does not work as expected. The labels are the >> >> literal strings containing LaTeX commands, not the LaTeX output. >> >> Adding in the commands under `# Text config` fixed at least that part >> >> of the issue. It seems to be caused by the fact that I am using a >> >> non-pgf backend by default. >> >> >> >> Regards, >> >> >> >> -Joe >> >> >> >> >> >> >> >> On Mon, Jul 11, 2016 at 12:35 PM, Jens Nielsen >> >> wrote: >> >> > I can confirm that this does not work as expected but I don't know >> >> > exactly >> >> > why. >> >> > >> >> > With regards to your pgf example. It seems to be missing a >> >> > \usepackage{dashrule} >> >> > >> >> > The following runs for me but still generates the black non colored >> >> > bars. >> >> > The # Text config seems to do nothing in my test so I'm not sure why >> >> > you >> >> > need to set it. >> >> > >> >> > If I save the pgf backend to a .pgf file and include it in a texfile >> >> > as >> >> > below everything looks correct in that example >> >> > >> >> > test.py >> >> > ``` >> >> > import matplotlib >> >> > from matplotlib.backends.backend_pgf import FigureCanvasPgf >> >> > matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) >> >> > from matplotlib import pyplot as plt >> >> > >> >> > matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v >> >> > preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) >> >> > preamble.append(r'\usepackage{color}') >> >> > preamble.append(r'\usepackage{dashrule}') >> >> > >> >> > # Text config >> >> > #matplotlib.rc('text', usetex=True) >> >> > # preamble = matplotlib.rcParams.setdefault('text.latex.preamble', >> >> > []) >> >> > #preamble.append(r'\usepackage{color}') >> >> > #preamble.append(r'\usepackage{dashrule}') >> >> > >> >> > ax = plt.plot((0, 1), (1, 2))[0].axes >> >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, >> >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') >> >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, >> >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') >> >> > plt.savefig('test.pgf') >> >> > plt.savefig('test.png') >> >> > ``` >> >> > >> >> > test.tex >> >> > ``` >> >> > \documentclass{article} >> >> > >> >> > \usepackage[utf8]{inputenc} >> >> > \usepackage[english]{babel} >> >> > >> >> > \usepackage{color} >> >> > \usepackage{dashrule} >> >> > \usepackage{pgf} >> >> > >> >> > \begin{document} >> >> > >> >> > \input{test.pgf} >> >> > \end{document} >> >> > ``` >> >> > >> >> > and running pdflatex test.tex generates a test.pdf that looks as >> >> > expected. >> >> > >> >> > best >> >> > Jens >> >> > >> >> > >> >> > >> >> > On Mon, 11 Jul 2016 at 17:08 Joseph Fox-Rabinovitz >> >> > wrote: >> >> >> >> >> >> Have an update on my previous question. I have tried to follow the >> >> >> instructions at http://matplotlib.org/users/pgf.html for settting up >> >> >> the PGF backend for PNG and PDF rendering. This method does not work >> >> >> either: >> >> >> >> >> >> import matplotlib as mpl >> >> >> from matplotlib.backends.backend_pgf import FigureCanvasPgf >> >> >> matplotlib.backend_bases.register_backend('png', >> >> >> FigureCanvasPgf) >> >> >> from matplotlib import pyplot as plt >> >> >> >> >> >> matplotlib.rc('pgf', texsystem='pdflatex') # from running latex >> >> >> -v >> >> >> preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) >> >> >> preamble.append(r'\usepackage{color}') >> >> >> >> >> >> # Text config >> >> >> matplotlib.rc('text', usetex=True) >> >> >> preamble = matplotlib.rcParams.setdefault('text.latex.preamble', >> >> >> []) >> >> >> preamble.append(r'\usepackage{color}') >> >> >> >> >> >> ax = plt.plot((0, 1), (1, 2))[0].axes >> >> >> ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, >> >> >> 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') >> >> >> ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, >> >> >> 0.0}{\rule[0.5ex]{3cm}{1pt}}') >> >> >> plt.savefig('test.png') >> >> >> >> >> >> Yields the exact same figure and PNG file with the incorrect black >> >> >> lines as above. Note that turning off the three lines under `# Text >> >> >> config` makes the TeX commands print out verbatim, even in the saved >> >> >> figure. Perhaps there is a way to render the PNG correctly without >> >> >> pre-clobbering with the text system? >> >> >> >> >> >> Regards, >> >> >> >> >> >> -Joe >> >> >> >> >> >> >> >> >> >> >> >> On Mon, Jul 11, 2016 at 11:12 AM, Joseph Fox-Rabinovitz >> >> >> wrote: >> >> >> > I originally posted to Stack Overflow at >> >> >> > http://stackoverflow.com/q/38274681/2988730 (and accidentally to >> >> >> > the >> >> >> > SourceForge version of this list). >> >> >> > >> >> >> > I am trying to follow the answer at >> >> >> > http://stackoverflow.com/a/38008501/2988730 to an earlier question >> >> >> > of >> >> >> > mine to create colored and styled legend-like entries. I have the >> >> >> > following code: >> >> >> > >> >> >> > import matplotlib as mpl >> >> >> > mpl.use('ps') >> >> >> > from matplotlib import pyplot as plt >> >> >> > >> >> >> > mpl.rc('text', usetex=True) >> >> >> > mpl.rc('text.latex', >> >> >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') >> >> >> > >> >> >> > plt.ion() >> >> >> > ax = plt.plot((0, 1), (1, 2))[0].axes >> >> >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, >> >> >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') >> >> >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, >> >> >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') >> >> >> > plt.savefig('test.ps') >> >> >> > >> >> >> > The result is as expected. The labels contain black text with a >> >> >> > red >> >> >> > line on the Y label and a green line on the X label: >> >> >> > http://i.stack.imgur.com/JCiLI.png. >> >> >> > >> >> >> > However, when I try the exact same set of commands without the >> >> >> > `mpl.use('ps')` line (using `'qt4agg'` backend on my system), the >> >> >> > figure neither saves corectly nor shows up correctly on screen: >> >> >> > >> >> >> > import matplotlib as mpl >> >> >> > from matplotlib import pyplot as plt >> >> >> > >> >> >> > mpl.rc('text', usetex=True) >> >> >> > mpl.rc('text.latex', >> >> >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') >> >> >> > >> >> >> > plt.ion() >> >> >> > ax = plt.plot((0, 1), (1, 2))[0].axes >> >> >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, >> >> >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') >> >> >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, >> >> >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') >> >> >> > >> >> >> > plt.savefig('test.png') >> >> >> > plt.show() >> >> >> > >> >> >> > The result of `plt.savefig` (http://i.stack.imgur.com/h2LXn.png) >> >> >> > and >> >> >> > `plt.show` (http://i.stack.imgur.com/0Ow7c.png) are basically the >> >> >> > same >> >> >> > in this case. The lines after the text show up black. >> >> >> > >> >> >> > How do I get the colors to show up in the labels with the default >> >> >> > interactive backend? >> >> >> > >> >> >> > Regards, >> >> >> > >> >> >> > -Joe >> >> >> _______________________________________________ >> >> >> Matplotlib-users mailing list >> >> >> Matplotlib-users at python.org >> >> >> https://mail.python.org/mailman/listinfo/matplotlib-users From jenshnielsen at gmail.com Mon Jul 11 15:45:54 2016 From: jenshnielsen at gmail.com (Jens Nielsen) Date: Mon, 11 Jul 2016 19:45:54 +0000 Subject: [Matplotlib-users] Creating Colored Axis Labels using LaTeX in Interactive Mode In-Reply-To: References: Message-ID: As I said I think there are 2 different issues and I don't think the PGF issue has anything todo with the preamble, the problem is that setting the pgf backend via registre_backend is ignored for png (but not for pdf) using matplotlib.use('pgf') and it seems to work as expected. The other issus not related to pgf is indirectly with the preamble because part of the preamble (what has to do with color is ignored on purpose to support the build in matplotlib text coloring) On Mon, 11 Jul 2016 at 20:37 Joseph Fox-Rabinovitz wrote: > I will put in a ticket shortly. I noticed that text latex preamble is > not supported according to the docs, but there is nothing about pgf > latex preamble. Perhaps the docs need to be updated there as well? > Either way, I don't think the issue is with the preamble at all, since > that seems to be importing the requested packages as expected. I think > the unicode link you posted has bearing on the issue, but I have not > experimented enough yet to know exactly how. > > Thanks, > > -Joe > > > > On Mon, Jul 11, 2016 at 3:19 PM, Jens Nielsen > wrote: > > Well pdf from the PGF backend also work as you expect for me > > > > Feel free to open a ticket but note that the latex preample is not > > officially supported. > > > > I suspect that the reason setting the color doesn't work is that the > > matplotlib default color handling overwrites it > > as in this example > > http://matplotlib.org/users/usetex.html#usetex-with-unicode that is > however > > not as easy if you only want to partially color the text > > > > > > > > > > On Mon, 11 Jul 2016 at 20:06 Joseph Fox-Rabinovitz > > wrote: > >> > >> It seems that for the time being, `use('ps')` is the only way to get > >> the rendering done correctly. I was hoping to get something that > >> rendered with partial accuracy in interactive mode while allowing me > >> to save correctly to a file. Any objections to me filing an issue > >> about this? > >> > >> Regards, > >> > >> -Joe > >> > >> > >> On Mon, Jul 11, 2016 at 2:55 PM, Jens Nielsen > >> wrote: > >> > You are right. I suspect that the register_backend logic does not work > >> > correctly for png. The code produces the expected results > >> > in pdf with register_backend and in both pdf and png if I do > >> > matplotlib.use('pgf') so it would seem like there are at least 2 > >> > different > >> > bugs. > >> > > >> > The color does not work with the regular latex text backend. > >> > > >> > register_backend does not work correctly with png and the pgf backend. > >> > > >> > best > >> > Jens > >> > > >> > > >> > > >> > > >> > On Mon, 11 Jul 2016 at 18:49 Joseph Fox-Rabinovitz > >> > wrote: > >> >> > >> >> Thanks for the catch with `\usepackage{dashrule}`. Using matplotlib > >> >> 1.5, the code you posted does not work as expected. The labels are > the > >> >> literal strings containing LaTeX commands, not the LaTeX output. > >> >> Adding in the commands under `# Text config` fixed at least that part > >> >> of the issue. It seems to be caused by the fact that I am using a > >> >> non-pgf backend by default. > >> >> > >> >> Regards, > >> >> > >> >> -Joe > >> >> > >> >> > >> >> > >> >> On Mon, Jul 11, 2016 at 12:35 PM, Jens Nielsen < > jenshnielsen at gmail.com> > >> >> wrote: > >> >> > I can confirm that this does not work as expected but I don't know > >> >> > exactly > >> >> > why. > >> >> > > >> >> > With regards to your pgf example. It seems to be missing a > >> >> > \usepackage{dashrule} > >> >> > > >> >> > The following runs for me but still generates the black non colored > >> >> > bars. > >> >> > The # Text config seems to do nothing in my test so I'm not sure > why > >> >> > you > >> >> > need to set it. > >> >> > > >> >> > If I save the pgf backend to a .pgf file and include it in a > texfile > >> >> > as > >> >> > below everything looks correct in that example > >> >> > > >> >> > test.py > >> >> > ``` > >> >> > import matplotlib > >> >> > from matplotlib.backends.backend_pgf import FigureCanvasPgf > >> >> > matplotlib.backend_bases.register_backend('png', FigureCanvasPgf) > >> >> > from matplotlib import pyplot as plt > >> >> > > >> >> > matplotlib.rc('pgf', texsystem='pdflatex') # from running latex -v > >> >> > preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) > >> >> > preamble.append(r'\usepackage{color}') > >> >> > preamble.append(r'\usepackage{dashrule}') > >> >> > > >> >> > # Text config > >> >> > #matplotlib.rc('text', usetex=True) > >> >> > # preamble = matplotlib.rcParams.setdefault('text.latex.preamble', > >> >> > []) > >> >> > #preamble.append(r'\usepackage{color}') > >> >> > #preamble.append(r'\usepackage{dashrule}') > >> >> > > >> >> > ax = plt.plot((0, 1), (1, 2))[0].axes > >> >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > >> >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > >> >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > >> >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > >> >> > plt.savefig('test.pgf') > >> >> > plt.savefig('test.png') > >> >> > ``` > >> >> > > >> >> > test.tex > >> >> > ``` > >> >> > \documentclass{article} > >> >> > > >> >> > \usepackage[utf8]{inputenc} > >> >> > \usepackage[english]{babel} > >> >> > > >> >> > \usepackage{color} > >> >> > \usepackage{dashrule} > >> >> > \usepackage{pgf} > >> >> > > >> >> > \begin{document} > >> >> > > >> >> > \input{test.pgf} > >> >> > \end{document} > >> >> > ``` > >> >> > > >> >> > and running pdflatex test.tex generates a test.pdf that looks as > >> >> > expected. > >> >> > > >> >> > best > >> >> > Jens > >> >> > > >> >> > > >> >> > > >> >> > On Mon, 11 Jul 2016 at 17:08 Joseph Fox-Rabinovitz > >> >> > wrote: > >> >> >> > >> >> >> Have an update on my previous question. I have tried to follow the > >> >> >> instructions at http://matplotlib.org/users/pgf.html for > settting up > >> >> >> the PGF backend for PNG and PDF rendering. This method does not > work > >> >> >> either: > >> >> >> > >> >> >> import matplotlib as mpl > >> >> >> from matplotlib.backends.backend_pgf import FigureCanvasPgf > >> >> >> matplotlib.backend_bases.register_backend('png', > >> >> >> FigureCanvasPgf) > >> >> >> from matplotlib import pyplot as plt > >> >> >> > >> >> >> matplotlib.rc('pgf', texsystem='pdflatex') # from running > latex > >> >> >> -v > >> >> >> preamble = matplotlib.rcParams.setdefault('pgf.preamble', []) > >> >> >> preamble.append(r'\usepackage{color}') > >> >> >> > >> >> >> # Text config > >> >> >> matplotlib.rc('text', usetex=True) > >> >> >> preamble = > matplotlib.rcParams.setdefault('text.latex.preamble', > >> >> >> []) > >> >> >> preamble.append(r'\usepackage{color}') > >> >> >> > >> >> >> ax = plt.plot((0, 1), (1, 2))[0].axes > >> >> >> ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > >> >> >> 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > >> >> >> ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > >> >> >> 0.0}{\rule[0.5ex]{3cm}{1pt}}') > >> >> >> plt.savefig('test.png') > >> >> >> > >> >> >> Yields the exact same figure and PNG file with the incorrect black > >> >> >> lines as above. Note that turning off the three lines under `# > Text > >> >> >> config` makes the TeX commands print out verbatim, even in the > saved > >> >> >> figure. Perhaps there is a way to render the PNG correctly without > >> >> >> pre-clobbering with the text system? > >> >> >> > >> >> >> Regards, > >> >> >> > >> >> >> -Joe > >> >> >> > >> >> >> > >> >> >> > >> >> >> On Mon, Jul 11, 2016 at 11:12 AM, Joseph Fox-Rabinovitz > >> >> >> wrote: > >> >> >> > I originally posted to Stack Overflow at > >> >> >> > http://stackoverflow.com/q/38274681/2988730 (and accidentally > to > >> >> >> > the > >> >> >> > SourceForge version of this list). > >> >> >> > > >> >> >> > I am trying to follow the answer at > >> >> >> > http://stackoverflow.com/a/38008501/2988730 to an earlier > question > >> >> >> > of > >> >> >> > mine to create colored and styled legend-like entries. I have > the > >> >> >> > following code: > >> >> >> > > >> >> >> > import matplotlib as mpl > >> >> >> > mpl.use('ps') > >> >> >> > from matplotlib import pyplot as plt > >> >> >> > > >> >> >> > mpl.rc('text', usetex=True) > >> >> >> > mpl.rc('text.latex', > >> >> >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') > >> >> >> > > >> >> >> > plt.ion() > >> >> >> > ax = plt.plot((0, 1), (1, 2))[0].axes > >> >> >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > >> >> >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > >> >> >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > >> >> >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > >> >> >> > plt.savefig('test.ps') > >> >> >> > > >> >> >> > The result is as expected. The labels contain black text with a > >> >> >> > red > >> >> >> > line on the Y label and a green line on the X label: > >> >> >> > http://i.stack.imgur.com/JCiLI.png. > >> >> >> > > >> >> >> > However, when I try the exact same set of commands without the > >> >> >> > `mpl.use('ps')` line (using `'qt4agg'` backend on my system), > the > >> >> >> > figure neither saves corectly nor shows up correctly on screen: > >> >> >> > > >> >> >> > import matplotlib as mpl > >> >> >> > from matplotlib import pyplot as plt > >> >> >> > > >> >> >> > mpl.rc('text', usetex=True) > >> >> >> > mpl.rc('text.latex', > >> >> >> > preamble='\\usepackage{color}\n\\usepackage{dashrule}') > >> >> >> > > >> >> >> > plt.ion() > >> >> >> > ax = plt.plot((0, 1), (1, 2))[0].axes > >> >> >> > ax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, > >> >> >> > 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}') > >> >> >> > ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, > >> >> >> > 0.0}{\rule[0.5ex]{3cm}{1pt}}') > >> >> >> > > >> >> >> > plt.savefig('test.png') > >> >> >> > plt.show() > >> >> >> > > >> >> >> > The result of `plt.savefig` (http://i.stack.imgur.com/h2LXn.png > ) > >> >> >> > and > >> >> >> > `plt.show` (http://i.stack.imgur.com/0Ow7c.png) are basically > the > >> >> >> > same > >> >> >> > in this case. The lines after the text show up black. > >> >> >> > > >> >> >> > How do I get the colors to show up in the labels with the > default > >> >> >> > interactive backend? > >> >> >> > > >> >> >> > Regards, > >> >> >> > > >> >> >> > -Joe > >> >> >> _______________________________________________ > >> >> >> Matplotlib-users mailing list > >> >> >> Matplotlib-users at python.org > >> >> >> https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From x.piter at gmail.com Tue Jul 12 09:35:22 2016 From: x.piter at gmail.com (Petro) Date: Tue, 12 Jul 2016 06:35:22 -0700 (MST) Subject: [Matplotlib-users] Image full screen In-Reply-To: References: Message-ID: <1468330522392-47290.post@n5.nabble.com> Hi. Here is an update. To remove window title and go into full screen mode, one can use: figManager = plt.get_current_fig_manager() figManager.full_screen_toggle() But I still cannot figure out how to remove a field where cursor coordinates are shown. Any suggestions? Thanks Petro -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Image-full-screen-tp47276p47290.html Sent from the matplotlib - users mailing list archive at Nabble.com. From vincent.adrien at gmail.com Tue Jul 12 12:32:39 2016 From: vincent.adrien at gmail.com (vincent.adrien at gmail.com) Date: Tue, 12 Jul 2016 18:32:39 +0200 Subject: [Matplotlib-users] Image full screen In-Reply-To: <1468330522392-47290.post@n5.nabble.com> References: <1468330522392-47290.post@n5.nabble.com> Message-ID: <57851BA7.9010605@gmail.com> Hi Petro, I succeeded in removing the bottom field where cursor coordinates are displayed by using: # fig = plt.gcf() fig.canvas.window().statusBar().setVisible(False) Hopefully it was what you were looking for. Adrien On 12/07/2016 15:35, Petro wrote: > Hi. > Here is an update. > To remove window title and go into full screen mode, one can use: > > figManager = plt.get_current_fig_manager() > figManager.full_screen_toggle() > > But I still cannot figure out how to remove a field where cursor coordinates > are shown. > > Any suggestions? > Thanks > Petro > > > > -- > View this message in context: http://matplotlib.1069221.n5.nabble.com/Image-full-screen-tp47276p47290.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > From bronger at physik.rwth-aachen.de Fri Jul 15 04:58:48 2016 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Fri, 15 Jul 2016 10:58:48 +0200 Subject: [Matplotlib-users] Spikes in small wedges of a pie chart Message-ID: <87y453e0qf.fsf@physik.rwth-aachen.de> Hall?chen! http://wilson.bronger.org/software.svg exhibits ugly spikes in the small wedges of this pie chart. After importing the SVG into Inkscape, the problem is even worse but can be fixed by changing the style of line vertices to "rounded". It may be a bug in the SVG-displaying software, however, maybe there is a workaround? I use Python3 + matplotlib 1.5.1. The code is: from matplotlib import pyplot import matplotlib figure = pyplot.figure() axes = figure.gca() axes.pie([23, 22, 2, 42, 1, 34, 17, 21, 15, 290, 897], labels=["Fedora", "CKAN", "dLibra" + 8 * " ", "DSpace", "eSciDoc", "DataVerse", "EPrints", "MySQL", "Nesstar", "sonstige", "unbekannt"], explode=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.15], wedgeprops={"clip_on": True, "capstyle": "round"}, shadow=True, startangle=150) axes.set_aspect("equal") figure.savefig("software.svg", bbox_inches="tight", transparent=True) Any help or workaround is appreciated. Thank you! Tsch?, Torsten. -- Torsten Bronger Jabber ID: torsten.bronger at jabber.rwth-aachen.de From x.piter at gmail.com Sun Jul 17 07:18:42 2016 From: x.piter at gmail.com (Petro) Date: Sun, 17 Jul 2016 04:18:42 -0700 (MST) Subject: [Matplotlib-users] Image full screen In-Reply-To: <57851BA7.9010605@gmail.com> References: <1468330522392-47290.post@n5.nabble.com> <57851BA7.9010605@gmail.com> Message-ID: <578B6984.5070204@gmail.com> Thanks Adrien, This is exactly what I wanted. On 07/12/2016 06:33 PM, vincent.adrien at gmail.com [via matplotlib] wrote: > Hi Petro, > > I succeeded in removing the bottom field where cursor coordinates are > displayed by using: > # fig = plt.gcf() > fig.canvas.window().statusBar().setVisible(False) > > Hopefully it was what you were looking for. > > Adrien > > > On 12/07/2016 15:35, Petro wrote: > > > Hi. > > Here is an update. > > To remove window title and go into full screen mode, one can use: > > > > figManager = plt.get_current_fig_manager() > > figManager.full_screen_toggle() > > > > But I still cannot figure out how to remove a field where cursor > coordinates > > are shown. > > > > Any suggestions? > > Thanks > > Petro > > > > > > > > -- > > View this message in context: > http://matplotlib.1069221.n5.nabble.com/Image-full-screen-tp47276p47290.html > > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > > _______________________________________________ > Matplotlib-users mailing list > [hidden email] > https://mail.python.org/mailman/listinfo/matplotlib-users > > > ------------------------------------------------------------------------ > If you reply to this email, your message will be added to the > discussion below: > http://matplotlib.1069221.n5.nabble.com/Image-full-screen-tp47276p47291.html > > To unsubscribe from Image full screen, click here > . > NAML > > -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Image-full-screen-tp47276p47307.html Sent from the matplotlib - users mailing list archive at Nabble.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From christine.e.smit at nasa.gov Fri Jul 22 14:24:08 2016 From: christine.e.smit at nasa.gov (Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]) Date: Fri, 22 Jul 2016 18:24:08 +0000 Subject: [Matplotlib-users] getting extra colors in figure Message-ID: Hi! I?m trying to plot data using imshow and ending up with more colors than I specify in the colormap. This is causing problems with a downstream user who is machine reading images to determine approximate data values based on colors. I think the issue has something to do with rounding because many colors in the image are only slightly off from the colors I specified. My plots have exactly one pixel per data value, so each pixel?s color should be exactly a color in the colormap. Here is an example that replicates the issue: ---------------------------------- import numpy as np; import matplotlib.pylab as plt import matplotlib.colors as colors from PIL import Image import random ####### # Create some simple data ####### shape = (8,12) npixels = shape[0]*shape[1] data_min = 0.5 data_max = 11.5 data = np.reshape(np.linspace(data_min,data_max,npixels),shape) # mask out a quarter of the pixels mask = np.reshape([False]*npixels,shape) half_width = int(shape[0]/2) half_height = int(shape[1]/2) mask[0:half_width,0:half_height] = True; ma = np.ma.MaskedArray(data = data,mask = mask) ####### # Create a color palette with three colors, one 'over' color, and one 'under' color ####### # define some colors in hex hex_colors = { 'red':'#ff0000', 'orange':"#ffa500", 'yellow': "#ffff00", 'green': "#00ff00", 'blue' : "#0000ff" } # Create the colormap cmap = colors.ListedColormap([hex_colors['orange'],hex_colors['yellow'],hex_colors ['green']]) cmap.set_under(color=hex_colors['red']) cmap.set_over(color=hex_colors['blue']) # Calculate boundaries between colors so we get some data in every color thresholds = np.linspace(data_min+1,data_max-1,cmap.N+1) norm = colors.BoundaryNorm(thresholds, cmap.N) ####### # Make a plot. The aim here is to have one data point per pixel in the output file with no # decorators. ####### # Step 1: turn off the frame fig = plt.figure(frameon=False) # Step 2: set the size of the image in inches to the number of data points. Note: the size is # specified width, height. fig.set_size_inches(shape[1], shape[0]) # Step 3: create Axes ax = plt.Axes(fig, [0., 0., 1., 1.]) # Step 4: turn off drawing axes ax.set_axis_off() # Step 5: add the axes to the figure fig.add_axes(ax) # Step 6: plot ax.imshow(ma, # Don't interpolate. There's no need to interpolate because we have # exactly as many data points as pixels. interpolation='none', # Use our 3-color (+1 above, +1 below) colormap cmap=cmap, # Use thresholds that will spread the data over all colors norm=norm, # Match image aspect ratio to axes aspect='auto', # Put ma[0,0] on the lower left origin='lower', # Lower left and upper right corners are at the edge of the image extent=(0,1,0,1) ) # Step 7: Save to file. fig.savefig('out.png', # Set dots per square inch (dpi) to 1. Since there is 1 data point # per inch, I should get an image with 1 data point for each pixel. dpi=1, # Set transparent to True so the masked data is transparent. transparent=True ) ####### # Open the image and see what colors are inside. I expect to see 6 colors: my 5 listed colors # and 1 transparent color for the masked data. ####### # Load the image im = Image.open("out.png") # Confirm that the image is the right size. Note: once again, the image size is width, height # while the data array is arranged height, width. print "Image size(should be %d x %d): %d x %d\n" %( shape[1], shape[0], im.size[0], im.size[1]) # Throw all the pixels, which are (red,green,blue,alpha) tuples, into a list pix = im.load() all_pix = [] width = im.size[0] for i in range(im.size[0]): for j in range(im.size[1]): all_pix.append(pix[i,j]) # Get a unique list of pixels unique = list(set(all_pix)) unique.sort() print "Unique pixels values in file:\n" for u in unique: print "%.2x %.2x %.2x (alpha - %.2x)" % (u[0],u[1],u[2], u[3]) print "\nNumber of unique colors (should be 6): %d" % len(unique) ---------------------------------- The output I get from this script is: ---------------------------------- Image size(should be 12 x 8): 12 x 8 Unique pixels values in file: 00 00 ff (alpha - ff) 00 fe 01 (alpha - ff) 00 ff 00 (alpha - ff) 01 00 00 (alpha - 01) 01 01 00 (alpha - 01) 02 02 00 (alpha - 02) fd ff 00 (alpha - ff) fe ff 00 (alpha - ff) ff 01 00 (alpha - ff) ff a5 00 (alpha - ff) ff a6 00 (alpha - ff) ff ff 00 (alpha - ff) ff ff ff (alpha - 00) Number of unique colors (should be 6): 13 ---------------------------------- Note the weird colors that weren?t in my colorbar. E.g. - 00 fe 01 (alpha - ff) --> close to 00 ff 00 (green) 01 00 00 (alpha - 00) --> close to transparent ff a6 00 (alpha - ff) --> close to ff a5 00 (orange) I am running Python 2.7.11 :: Anaconda 2.4.0 (64-bit) and matplotlib version 1.4.3. I tried matplotlib 1.5 and it had the same issue. Thanks. Christine From antony.lee at berkeley.edu Sun Jul 24 20:41:18 2016 From: antony.lee at berkeley.edu (Antony Lee) Date: Sun, 24 Jul 2016 17:41:18 -0700 Subject: [Matplotlib-users] New "data cursors for matplotlib" package: https://github.com/anntzer/mplcursors Message-ID: Hi all, I have written a new "data cursors for matplotlib" package, inspired from @joferkington's mpldatacursor but rewritten from scratch, with a much simpler API. Please have a look at https://github.com/anntzer/mplcursors . I hope you'll like it. Antony -------------- next part -------------- An HTML attachment was scrubbed... URL: From efiring at hawaii.edu Tue Jul 26 03:11:27 2016 From: efiring at hawaii.edu (Eric Firing) Date: Mon, 25 Jul 2016 21:11:27 -1000 Subject: [Matplotlib-users] getting extra colors in figure In-Reply-To: References: Message-ID: On 2016/07/22 8:24 AM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] wrote: > Hi! I?m trying to plot data using imshow and ending up with more colors > than I specify in the colormap. This is causing problems with a downstream > user who is machine reading images to determine approximate data values > based on colors. I think the issue has something to do with rounding > because many colors in the image are only slightly off from the colors I > specified. My plots have exactly one pixel per data value, so each pixel?s > color should be exactly a color in the colormap. > Christine, I can reproduce this on 1.5.1, and on what will become 1.5.3 (the last of the 1.5 series) but not on the github branch for the upcoming 2.0 release. Presumably the major image overhaul for 2.0 has fixed the problem--even though it was most likely a problem no one knew we had. Eric From Nicolas.Rougier at inria.fr Tue Jul 26 03:30:32 2016 From: Nicolas.Rougier at inria.fr (Nicolas P. Rougier) Date: Tue, 26 Jul 2016 09:30:32 +0200 Subject: [Matplotlib-users] getting extra colors in figure In-Reply-To: References: Message-ID: <9CBBC940-F184-457B-8688-D3AF1095EF60@inria.fr> I think Michael explained this bug during his lighting talk at Scipy 2016: https://www.youtube.com/watch?v=0FVK-X_4wHs (time 56:00) The problem is that interpolation is made on colorspace and not dataspace. Nicolas > On 26 Jul 2016, at 09:11, Eric Firing wrote: > > On 2016/07/22 8:24 AM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] wrote: >> Hi! I?m trying to plot data using imshow and ending up with more colors >> than I specify in the colormap. This is causing problems with a downstream >> user who is machine reading images to determine approximate data values >> based on colors. I think the issue has something to do with rounding >> because many colors in the image are only slightly off from the colors I >> specified. My plots have exactly one pixel per data value, so each pixel?s >> color should be exactly a color in the colormap. >> > > Christine, > > I can reproduce this on 1.5.1, and on what will become 1.5.3 (the last of the 1.5 series) but not on the github branch for the upcoming 2.0 release. Presumably the major image overhaul for 2.0 has fixed the problem--even though it was most likely a problem no one knew we had. > > Eric > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users From christine.e.smit at nasa.gov Tue Jul 26 09:53:45 2016 From: christine.e.smit at nasa.gov (Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]) Date: Tue, 26 Jul 2016 13:53:45 +0000 Subject: [Matplotlib-users] getting extra colors in figure In-Reply-To: <9CBBC940-F184-457B-8688-D3AF1095EF60@inria.fr> References: <9CBBC940-F184-457B-8688-D3AF1095EF60@inria.fr> Message-ID: Thanks Nick and Eric! At least I now know why this happening. On 7/26/16, 3:30 AM, "Matplotlib-users on behalf of Nicolas P. Rougier" wrote: > >I think Michael explained this bug during his lighting talk at Scipy 2016: > >https://www.youtube.com/watch?v=0FVK-X_4wHs (time 56:00) > >The problem is that interpolation is made on colorspace and not dataspace. > > >Nicolas > > > > >> On 26 Jul 2016, at 09:11, Eric Firing wrote: >> >> On 2016/07/22 8:24 AM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] >>wrote: >>> Hi! I?m trying to plot data using imshow and ending up with more colors >>> than I specify in the colormap. This is causing problems with a >>>downstream >>> user who is machine reading images to determine approximate data values >>> based on colors. I think the issue has something to do with rounding >>> because many colors in the image are only slightly off from the colors >>>I >>> specified. My plots have exactly one pixel per data value, so each >>>pixel?s >>> color should be exactly a color in the colormap. >>> >> >> Christine, >> >> I can reproduce this on 1.5.1, and on what will become 1.5.3 (the last >>of the 1.5 series) but not on the github branch for the upcoming 2.0 >>release. Presumably the major image overhaul for 2.0 has fixed the >>problem--even though it was most likely a problem no one knew we had. >> >> Eric >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users > >_______________________________________________ >Matplotlib-users mailing list >Matplotlib-users at python.org >https://mail.python.org/mailman/listinfo/matplotlib-users From efiring at hawaii.edu Tue Jul 26 13:47:11 2016 From: efiring at hawaii.edu (Eric Firing) Date: Tue, 26 Jul 2016 07:47:11 -1000 Subject: [Matplotlib-users] getting extra colors in figure In-Reply-To: References: Message-ID: <783d1305-f656-d9cb-6ac8-9715943bedd7@hawaii.edu> On 2016/07/22 8:24 AM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] wrote: > Hi! I?m trying to plot data using imshow and ending up with more colors > than I specify in the colormap. This is causing problems with a downstream > user who is machine reading images to determine approximate data values > based on colors. I think the issue has something to do with rounding > because many colors in the image are only slightly off from the colors I > specified. My plots have exactly one pixel per data value, so each pixel?s > color should be exactly a color in the colormap. Christine, To solve the problem, try using interpolation = 'nearest' rather than 'none'. The distinction between these is two is endlessly confusing, but http://matplotlib.org/examples/images_contours_and_fields/interpolation_none_vs_nearest.html is an attempt to illustrate it. In your example, with "nearest" I get 5 unique colors, not 6. Eric From christine.e.smit at nasa.gov Tue Jul 26 14:12:29 2016 From: christine.e.smit at nasa.gov (Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]) Date: Tue, 26 Jul 2016 18:12:29 +0000 Subject: [Matplotlib-users] getting extra colors in figure In-Reply-To: <783d1305-f656-d9cb-6ac8-9715943bedd7@hawaii.edu> References: <783d1305-f656-d9cb-6ac8-9715943bedd7@hawaii.edu> Message-ID: Thanks! I actually used ?nearest? before, but then ran into another issue: https://github.com/matplotlib/matplotlib/issues/5520. It looks as though the issue has been fixed, but I?m not sure where. The tag suggests to me that it will be fixed in matplotlib 2.0. I think that in this case matplotlib may actually be overkill. We are just writing one pixel per data point, so I think it may be easier to just write the png directly. Christine On 7/26/16, 1:47 PM, "Matplotlib-users on behalf of Eric Firing" wrote: >On 2016/07/22 8:24 AM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] >wrote: >> Hi! I?m trying to plot data using imshow and ending up with more colors >> than I specify in the colormap. This is causing problems with a >>downstream >> user who is machine reading images to determine approximate data values >> based on colors. I think the issue has something to do with rounding >> because many colors in the image are only slightly off from the colors I >> specified. My plots have exactly one pixel per data value, so each >>pixel?s >> color should be exactly a color in the colormap. > >Christine, > >To solve the problem, try using interpolation = 'nearest' rather than >'none'. The distinction between these is two is endlessly confusing, >but >http://matplotlib.org/examples/images_contours_and_fields/interpolation_no >ne_vs_nearest.html >is an attempt to illustrate it. > >In your example, with "nearest" I get 5 unique colors, not 6. > >Eric >_______________________________________________ >Matplotlib-users mailing list >Matplotlib-users at python.org >https://mail.python.org/mailman/listinfo/matplotlib-users From antony.lee at berkeley.edu Tue Jul 26 14:18:54 2016 From: antony.lee at berkeley.edu (Antony Lee) Date: Tue, 26 Jul 2016 11:18:54 -0700 Subject: [Matplotlib-users] getting extra colors in figure In-Reply-To: <783d1305-f656-d9cb-6ac8-9715943bedd7@hawaii.edu> References: <783d1305-f656-d9cb-6ac8-9715943bedd7@hawaii.edu> Message-ID: It may be worth adding a note to the example as to why this distinction exists? Right now it's a bit "magical"... Antony 2016-07-26 10:47 GMT-07:00 Eric Firing : > On 2016/07/22 8:24 AM, Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP] > wrote: > >> Hi! I?m trying to plot data using imshow and ending up with more colors >> than I specify in the colormap. This is causing problems with a downstream >> user who is machine reading images to determine approximate data values >> based on colors. I think the issue has something to do with rounding >> because many colors in the image are only slightly off from the colors I >> specified. My plots have exactly one pixel per data value, so each pixel?s >> color should be exactly a color in the colormap. >> > > Christine, > > To solve the problem, try using interpolation = 'nearest' rather than > 'none'. The distinction between these is two is endlessly confusing, but > http://matplotlib.org/examples/images_contours_and_fields/interpolation_none_vs_nearest.html > is an attempt to illustrate it. > > In your example, with "nearest" I get 5 unique colors, not 6. > > Eric > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Thu Jul 28 12:51:23 2016 From: ben.v.root at gmail.com (Benjamin Root) Date: Thu, 28 Jul 2016 12:51:23 -0400 Subject: [Matplotlib-users] [Matplotlib-devel] New "data cursors for matplotlib" package: https://github.com/anntzer/mplcursors In-Reply-To: References: Message-ID: Hey, that is pretty slick! I especially like the decorator option to connecting events to the cursor objects. Kudos! Ben Root On Sun, Jul 24, 2016 at 8:41 PM, Antony Lee wrote: > Hi all, > > I have written a new "data cursors for matplotlib" package, inspired from > @joferkington's mpldatacursor but rewritten from scratch, with a much > simpler API. Please have a look at https://github.com/anntzer/mplcursors > . > > I hope you'll like it. > > Antony > > _______________________________________________ > Matplotlib-devel mailing list > Matplotlib-devel at python.org > https://mail.python.org/mailman/listinfo/matplotlib-devel > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From antony.lee at berkeley.edu Thu Jul 28 14:09:27 2016 From: antony.lee at berkeley.edu (Antony Lee) Date: Thu, 28 Jul 2016 11:09:27 -0700 Subject: [Matplotlib-users] [Matplotlib-devel] New "data cursors for matplotlib" package: https://github.com/anntzer/mplcursors In-Reply-To: References: Message-ID: 2016-07-28 9:51 GMT-07:00 Benjamin Root : > Hey, that is pretty slick! I especially like the decorator option to > connecting events to the cursor objects. > This is a pretty common pattern nowadays, probably could be added to matplotlib's event handling code itself. > > Kudos! > > Ben Root > > On Sun, Jul 24, 2016 at 8:41 PM, Antony Lee > wrote: > >> Hi all, >> >> I have written a new "data cursors for matplotlib" package, inspired from >> @joferkington's mpldatacursor but rewritten from scratch, with a much >> simpler API. Please have a look at https://github.com/anntzer/mplcursors >> . >> >> I hope you'll like it. >> >> Antony >> >> _______________________________________________ >> Matplotlib-devel mailing list >> Matplotlib-devel at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-devel >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From story645 at gmail.com Fri Jul 29 16:25:58 2016 From: story645 at gmail.com (Hannah) Date: Fri, 29 Jul 2016 16:25:58 -0400 Subject: [Matplotlib-users] Call for Abstracts: AMS 2017 Python Symposium Message-ID: The Core Science Keynote for the AMS2017 Python Symposium will be given by matplotlib contributor Ryan May (@dopplershift). The Seventh Symposium on Advances in Modeling and Analysis Using Python, sponsored by the American Meteorological Society, and organized by the AMS Board on Environmental Information Processing Technologies, will be held 22?26 January 2017, as part of the 97th AMS Annual Meeting in Seattle, Washington. Preliminary programs, registration, hotel, and general information will be posted on the AMS Web site in late-September 2016. Abstract submissions for the Python Symposium should be submitted via the AMS web site by 3 August 2016. The theme for the 2017 AMS Annual Meeting is ?Observations Lead the Way?. For the full description of the theme, please visit the AMS 2017 Annual Meeting Web page . Papers for this conference are solicited on - Modeling - Time series analysis - Air quality - Satellite data processing - In-situ data analysis - GIS - Python as a software integration platform - Visualization - Gridding - Model intercomparison and ensembles - Data intensive computation and big data - Teaching and learning Python - Connecting Python with other languages The $95 abstract fee includes the submission of your abstract, the posting of your extended abstract, and the uploading and recording of your presentation which will be archived on the AMS Web site. Please submit your abstract electronically via the AMS web site by 3 August 2016. An abstract fee of $95 (payable by credit card or purchase order) is charged at the time of submission (refundable only if abstract is not accepted). Authors of accepted presentations will be notified via e-mail by late-September 2016. All extended abstracts are to be submitted electronically and will be available on-line via the Web. Instructions for formatting extended abstracts will be posted on the AMS Web site. Authors have the option to submit manuscripts (up to 10 MB) electronically by 27 February 2017. All abstracts, extended abstracts and presentations will be available on the AMS Web site at no cost. For additional information please contact the program chairperson(s), Johnny Lin (email:johnny at johnny-lin.com) -------------- next part -------------- An HTML attachment was scrubbed... URL: From nollroberts at gmail.com Sun Jul 31 13:16:50 2016 From: nollroberts at gmail.com (Noll) Date: Sun, 31 Jul 2016 11:16:50 -0600 Subject: [Matplotlib-users] post Message-ID: To anyone interested in developing democratic software, consider reading: https://amodicumofdemocracy.wordpress.com/2016/07/29/population-based-democratic-majority-decision-making-rough-draft/ ? and post any comments, questions, or concerns.? -- Noll Roberts nollroberts at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jon.roadleybattin at gmail.com Sun Jul 31 15:58:00 2016 From: jon.roadleybattin at gmail.com (Jon Roadley-Battin) Date: Sun, 31 Jul 2016 20:58:00 +0100 Subject: [Matplotlib-users] Optimally displaying 7 X-Y plots in one window Message-ID: Good evening, I manage a small application where I work that captures data from some bespoke hardware (via USB) and if so which, plot 7 channels. At the moment I just plot the 7 waveforms, with a bit of decorating and for the most part this is fine. There are some relatively common occurrences of data which makes viewing within the application ... tricky Say for insta -------------- next part -------------- An HTML attachment was scrubbed... URL: From jenshnielsen at gmail.com Sun Jul 31 16:07:22 2016 From: jenshnielsen at gmail.com (Jens Nielsen) Date: Sun, 31 Jul 2016 20:07:22 +0000 Subject: [Matplotlib-users] Optimally displaying 7 X-Y plots in one window In-Reply-To: References: Message-ID: did you sent this a bit to early. The last sentence seems to finish rather abruptly On Sun, 31 Jul 2016 at 20:58 Jon Roadley-Battin wrote: > Good evening, > > I manage a small application where I work that captures data from some > bespoke hardware (via USB) and if so which, plot 7 channels. > > At the moment I just plot the 7 waveforms, with a bit of decorating and > for the most part this is fine. There are some relatively common > occurrences of data which makes viewing within the application ... tricky > > Say for insta > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jon.roadleybattin at gmail.com Sun Jul 31 16:08:05 2016 From: jon.roadleybattin at gmail.com (Jon Roadley-Battin) Date: Sun, 31 Jul 2016 21:08:05 +0100 Subject: [Matplotlib-users] Data representation improvements Message-ID: Good evening. For some time now I have managed an application which acquires data from bespoke hardware & optionally plots upto seven channels. Matplotlib is embedded within a QT4 application & the "plotting" interface is almost fully for matplotlib. I have managed to free up some spare time from my main role & I would like to vastly improve the representation of the data to the users in light of some in-use observation. The data is being acquired from a motor-drive & so there is some sinus data ( the motor's currents... 50Hz, 100A peak), data like speed (mostly DC around 3000rpm with some ripple...) and then some digital flag (16bit data...) The fixed point data are (luckily) all relatively low in magnitude ... and so plotting a 3000-value and a 100pk value is still visible, be it small amplitude BUT the moment I plot one of the digital flag registers, these dwarf the fixed-point data. To help with the I have provided means to "hide" channels but I was wondering if there is any better way? I have considered 7 stacked x-y subplots but this will eat into vertical re-estate very quickly. I have played with secondary y-axis but this equally ends up taking a lot of horizontal re-estate. I have considered plotting the digital registers akin to a digital vector so they are small, heightwise, plots as this will alleviate part of the concerns. Any advice with regards to a usable presentation Example code for multiple y-axis import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import host_subplot import mpl_toolkits.axisartist as AA import numpy as np t = np.arange(0,1,0.00001) data = [5000*np.sin(t*2*np.pi*10), 10*np.sin(t*2*np.pi*20), 20*np.sin(t*2*np.pi*30), np.sin(t*2*np.pi*40)+5000, np.sin(t*2*np.pi*50)-5000, np.sin(t*2*np.pi*60), np.sin(t*2*np.pi*70), ] fig = plt.figure() host = host_subplot(111, axes_class=AA.Axes) axis_list = [None]*7 for i in range(len(axis_list)): axis_list[i] = host.twinx() new_axis = axis_list[i].get_grid_helper().new_fixed_axis axis_list[i].axis['right'] = new_axis(loc='right', axes=axis_list[i], offset=(60*i,0)) axis_list[i].axis['right'].toggle(all=True) axis_list[i].plot(t,data[i]) plt.show() for i in data: plt.plot(t,i) plt.show() Yours, JonRB -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Sun Jul 31 18:32:08 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Sun, 31 Jul 2016 22:32:08 +0000 Subject: [Matplotlib-users] mpl governance Message-ID: Folks, During the sprints at SciPy Mike Droettboom and I started to adapt the Jupyter governance documents for matplotlib. We are doing this in the open, and a pull request of the changes is at: https://github.com/matplotlib/governance/pull/1 To be clear, this is a work in progress and is not final or in force. We propose the mechanism for ratifying the these documents is to, after input from the community, have the current "matplotlib Executive Committee" (the signers of the FSA with NUMFocus) vote. Tom ps A very similar email was sent to the matplotlib-devel list on July 17 -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Sun Jul 31 18:36:54 2016 From: tcaswell at gmail.com (Thomas Caswell) Date: Sun, 31 Jul 2016 22:36:54 +0000 Subject: [Matplotlib-users] [Matplotlib-announce] mpl governance In-Reply-To: <78DF05A1-B472-4577-B101-1D23F6C3F5F9@gmail.com> References: <78DF05A1-B472-4577-B101-1D23F6C3F5F9@gmail.com> Message-ID: I am not sure what you mean. On Sun, Jul 31, 2016, 18:35 Dipankar ?Dipu? Ganguly wrote: > How will this impact on the image processing aspects? > > Dipu > > > Dipankar Ganguly > Consultant: Strategy/Technology/Commercialization > Bothell, WA > Cell: 408-203-8814 > email: dipugee at gmail.com > http://www.linkedin.com/in/dipugee > > > > > > > > > > On Jul 31, 2016, at 3:32 PM, Thomas Caswell wrote: > > Folks, > > During the sprints at SciPy Mike Droettboom and I started to adapt the > Jupyter governance documents for matplotlib. > > We are doing this in the open, and a pull request of the changes is at: > > https://github.com/matplotlib/governance/pull/1 > > To be clear, this is a work in progress and is not final or in force. > > We propose the mechanism for ratifying the these documents is to, after > input from the community, have the current "matplotlib Executive Committee" > (the signers of the FSA with NUMFocus) vote. > > Tom > > ps A very similar email was sent to the matplotlib-devel list on July 17 > > > ------------------------------------------------------------------------------ > _______________________________________________ > Matplotlib-announce mailing list > Matplotlib-announce at lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-announce > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wrw at mac.com Sun Jul 31 18:11:23 2016 From: wrw at mac.com (William Ray Wing) Date: Sun, 31 Jul 2016 18:11:23 -0400 Subject: [Matplotlib-users] Data representation improvements In-Reply-To: References: Message-ID: <8F73942A-96A8-4CAF-BCCF-178F56DBAB35@mac.com> > On Jul 31, 2016, at 4:08 PM, Jon Roadley-Battin wrote: > > Good evening. > > For some time now I have managed an application which acquires data from bespoke hardware & optionally plots upto seven channels. Matplotlib is embedded within a QT4 application & the "plotting" interface is almost fully for matplotlib. > > I have managed to free up some spare time from my main role & I would like to vastly improve the representation of the data to the users in light of some in-use observation. > > The data is being acquired from a motor-drive & so there is some sinus data ( the motor's currents... 50Hz, 100A peak), data like speed (mostly DC around 3000rpm with some ripple...) and then some digital flag (16bit data...) > > The fixed point data are (luckily) all relatively low in magnitude ... and so plotting a 3000-value and a 100pk value is still visible, be it small amplitude BUT the moment I plot one of the digital flag registers, these dwarf the fixed-point data. > Please tell us a bit more about those digital flag registers. Are they 16 independent status flags, for example, or something more correlated? If they really are 16 independent flags, the traditional way to deal with that sort of thing is to plot them as 16 separate strip-chart lines, with vertical values of 1 or 0. They can be fairly close together, consume relatively little vertical plotting space, and still clearly show when one of the states has changed. Bill > To help with the I have provided means to "hide" channels but I was wondering if there is any better way? > > I have considered 7 stacked x-y subplots but this will eat into vertical re-estate very quickly. > > I have played with secondary y-axis but this equally ends up taking a lot of horizontal re-estate. > > I have considered plotting the digital registers akin to a digital vector so they are small, heightwise, plots as this will alleviate part of the concerns. > > Any advice with regards to a usable presentation > > > > Example code for multiple y-axis > > import matplotlib.pyplot as plt > from mpl_toolkits.axes_grid1 import host_subplot > import mpl_toolkits.axisartist as AA > import numpy as np > > t = np.arange(0,1,0.00001) > data = [5000*np.sin(t*2*np.pi*10), > 10*np.sin(t*2*np.pi*20), > 20*np.sin(t*2*np.pi*30), > np.sin(t*2*np.pi*40)+5000, > np.sin(t*2*np.pi*50)-5000, > np.sin(t*2*np.pi*60), > np.sin(t*2*np.pi*70), > ] > > fig = plt.figure() > host = host_subplot(111, axes_class=AA.Axes) > > axis_list = [None]*7 > for i in range(len(axis_list)): > axis_list[i] = host.twinx() > new_axis = axis_list[i].get_grid_helper().new_fixed_axis > axis_list[i].axis['right'] = new_axis(loc='right', > axes=axis_list[i], > offset=(60*i,0)) > axis_list[i].axis['right'].toggle(all=True) > axis_list[i].plot(t,data[i]) > > plt.show() > > for i in data: > plt.plot(t,i) > plt.show() > > > Yours, > > JonRB > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users From dipugee at gmail.com Sun Jul 31 23:40:09 2016 From: dipugee at gmail.com (=?utf-8?Q?Dipankar_=E2=80=9CDipu=E2=80=9D_Ganguly?=) Date: Sun, 31 Jul 2016 20:40:09 -0700 Subject: [Matplotlib-users] Matplotlib for image processing Message-ID: <1AF2F015-0D03-40A7-8980-E27682CB804A@gmail.com> I am trying to teach myself matplotlib for my latest image processing project as a replacement for Matlab. I am also using Jupyter. Any pointers to tutorials and/or documents on the topic would be very helpful indeed Thanks Dipu Dipankar ?Dipu? Ganguly Consultant: Strategy/Technology/Commercialization Bothell, WA Cell: 408-203-8814 email: dipugee at gmail.com http://www.linkedin.com/in/dipugee -------------- next part -------------- An HTML attachment was scrubbed... URL: