From edgar at openmail.cc Sun Nov 4 03:17:43 2018 From: edgar at openmail.cc (edgar at openmail.cc) Date: Sun, 04 Nov 2018 08:17:43 +0000 Subject: [Matplotlib-users] latex with graphical backend and svg savefig Message-ID: <37b98603fee545d679330bc0d06032a9@openmail.cc> Hello, 1. I want to report a possible issue (I don't want an account on GitHub... Micro$hit): texmanager.py has @ line 251: if rcParams['text.latex.unicode']: unicode_preamble = r""" \usepackage[utf8]{inputenc}""" else: unicode_preamble = '' @ line 299: if rcParams['text.latex.unicode']: fh.write(s.encode('utf8')) Due to font conflicts in my system [1], I need \usepackage{lmodern} \usepackage[QX]{fontenc} (I tried with DejaVu Sans, without success). Adding it to the rcParams in the text.latex.preamble does not help, because inputenc clashes with that. In another computer, if I disable text.latex.unicode , Matplotlib tries to use ASCII, which creates an error. I suggest that the first conditional is removed (since text.latex.unicode is depreceated anyway), but I don't know how the unicode characters are going to be handled once that depreciation happens (second conditional). Again, I didn't get that issue (ASCII) with Parabola. 2. I want a SVG and to be able to show the figure on screen (possibly save it from the new window). How can I achieve that? This [2] didn't work. ! Font TS1/cmr/m/it/16=tcti1728 at 17.28pt not loadable: Metric (TFM) file not found. relax l.14 ...0000}{\rmfamily \textit{Velocity (?/sec)} } My failed attempt is below [3] I tried to make this clear, but let me know if something needs clarification. Thanks! My system: Parabola GNU/Linux pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) matplotlib._version.get_versions() {'dirty': False, 'error': None, 'full-revisionid': '682e5195fae83393a75c71e84d1434cc9ff255fb', 'version': '3.0.1'} (installed with pip) [1] https://wiki.parabola.nu/TeXLive [2] https://matplotlib.org/gallery/text_labels_and_annotations/tex_demo.html#sphx-glr-gallery-text-labels-and-annotations-tex-demo-py [3] import matplotlib as mpl from matplotlib import pyplot as pl # https://tex.stackexchange.com/a/391078 # https://3diagramsperpage.wordpress.com/category/matplotlib/ family = "DejaVu Sans" serif, sans_serif, mono = [family] * 3 size = 14 labelsize = 12 legfontsize = 10 ticksize = 10 pgf_with_latex = { # setup matplotlib to use latex for output "text.usetex": True, # use LaTeX to write all text # "text.latex.unicode": True, # https://github.com/MaxNoe/python-plotting/blob/master/source/siunitx_ticks.py "font.family": family, "font.serif": serif, # blank entries should cause plots "font.sans-serif": sans_serif, # to inherit fonts from the document "font.monospace": mono, # LaTeX default is 10pt font. "axes.labelsize": labelsize, "font.size": size, "legend.fontsize": legfontsize, # Make the legend/label fonts "xtick.labelsize": ticksize, # a little smaller "ytick.labelsize": ticksize, "text.latex.preamble": [ # plots will be generated using this preamble # r"\usepackage[utf8x]{inputenc}", # use utf8 fonts r"\usepackage{lmodern} \usepackage[QX]{fontenc}", r"\usepackage[detect-all]{siunitx}", ] } mpl.rcParams.update(pgf_with_latex) pl.plot([1e-6, 2e-6], label=r"?") pl.legend() pl.show() ------------------------------------------------- ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands! $24.95 ONETIME Lifetime accounts with Privacy Features! 15GB disk! No bandwidth quotas! Commercial and Bulk Mail Options! From jni.soma at gmail.com Wed Nov 7 16:37:51 2018 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Wed, 07 Nov 2018 16:37:51 -0500 Subject: [Matplotlib-users] Using Matplotlib nbagg for _repr_html_ for notebooks Message-ID: <912ba95f-79ec-478b-ae5d-8951f1d4b141@sloti1d3t01> Hi, I'm working on a class to which I would like to add a _repr_html_ [1] method for display in Jupyter notebooks. Is there a way to generate a matplotlib notebook backend view "offline" (not using pyplot, since that will behave differently depending on the currently active backend), and then return the corresponding html? Thanks, Juan. .. [1]: https://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display -------------- next part -------------- An HTML attachment was scrubbed... URL: From jni.soma at gmail.com Wed Nov 7 19:24:45 2018 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Wed, 07 Nov 2018 19:24:45 -0500 Subject: [Matplotlib-users] =?utf-8?q?Using_Matplotlib_nbagg_for_=5Frepr?= =?utf-8?q?=5Fhtml=5F_for_notebooks?= In-Reply-To: References: <912ba95f-79ec-478b-ae5d-8951f1d4b141@sloti1d3t01> Message-ID: Thanks Tom! My question is, would it be possible for the html to contain the interactive MPL figure, as returned by the notebook backend? There's also _repr_javascript_ it turns out. But yes, this is already great, I can use this for _repr_png_. I'm targeting 3.0+ so "new enough matplotlib" shouldn't be an issue. =) Juan. On Thu, Nov 8, 2018, at 11:16 AM, Thomas Caswell wrote: > Something like: > > ``` > from matplotlib.figure import Figure > from matplotlib.backends.backend_agg import FigureCanvas > > fig = Figure() > canvas = FigureCanvas(fig) # this step will be optional in mpl 3.1 (and current master) > > ax = fig.subplots() # assuming new enough matplotlib > ``` > > or one of the other backends. If you are doing this for a htmlrepr you likely want to also do > > ``` > output = BytesIO() > fig.savefig(output, format='png') > ``` > > to get the image as a buffer you can inject into the repr (or SVG?) > > Hope that helps! > > Tom > > On Wed, Nov 7, 2018 at 4:38 PM Juan Nunez-Iglesias wrote: >> __ >> Hi, >> >> I'm working on a class to which I would like to add a _repr_html_ [1] method for display in Jupyter notebooks. Is there a way to generate a matplotlib notebook backend view "offline" (not using pyplot, since that will behave differently depending on the currently active backend), and then return the corresponding html? >> >> Thanks, >> >> Juan. >> >> .. [1]: https://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users > > > -- > Thomas Caswell > tcaswell at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Fri Nov 9 16:23:22 2018 From: tcaswell at gmail.com (Thomas Caswell) Date: Fri, 9 Nov 2018 16:23:22 -0500 Subject: [Matplotlib-users] Using Matplotlib nbagg for _repr_html_ for notebooks In-Reply-To: References: <912ba95f-79ec-478b-ae5d-8951f1d4b141@sloti1d3t01> Message-ID: Ah, I misunderstood! In that case I suggest looking at ipympl / jupyter-matplotlib (which is a ipywidget based backend). I suspect you can use the same process to get a rendered canvas, and there is likely a way to extract the widget objects from it. Tom On Wed, Nov 7, 2018 at 7:24 PM Juan Nunez-Iglesias wrote: > Thanks Tom! > > My question is, would it be possible for the html to contain the > interactive MPL figure, as returned by the notebook backend? There's also > _repr_javascript_ it turns out. > > But yes, this is already great, I can use this for _repr_png_. > > I'm targeting 3.0+ so "new enough matplotlib" shouldn't be an issue. =) > > Juan. > > On Thu, Nov 8, 2018, at 11:16 AM, Thomas Caswell wrote: > > Something like: > > ``` > from matplotlib.figure import Figure > from matplotlib.backends.backend_agg import FigureCanvas > > fig = Figure() > canvas = FigureCanvas(fig) # this step will be optional in mpl 3.1 (and > current master) > > ax = fig.subplots() # assuming new enough matplotlib > ``` > > or one of the other backends. If you are doing this for a htmlrepr you > likely want to also do > > ``` > output = BytesIO() > fig.savefig(output, format='png') > ``` > > to get the image as a buffer you can inject into the repr (or SVG?) > > Hope that helps! > > Tom > > On Wed, Nov 7, 2018 at 4:38 PM Juan Nunez-Iglesias > wrote: > > > Hi, > > I'm working on a class to which I would like to add a _repr_html_ [1] > method for display in Jupyter notebooks. Is there a way to generate a > matplotlib notebook backend view "offline" (not using pyplot, since that > will behave differently depending on the currently active backend), and > then return the corresponding html? > > Thanks, > > Juan. > > .. [1]: > https://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > > > > -- > Thomas Caswell > tcaswell at gmail.com > > > -- Thomas Caswell tcaswell at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Sun Nov 11 01:02:48 2018 From: tcaswell at gmail.com (Thomas Caswell) Date: Sun, 11 Nov 2018 17:02:48 +1100 Subject: [Matplotlib-users] [REL] Matplotlib v3.0.1 and v3.0.2 Message-ID: Folks, Happy to announce the second bug-fix release for the Matplotlib 3.0 series. REL: v3.0.2 This is the second bug-fix release for the v3.0 series. - Un-breaks basemap which was broken by partially restoring private APIs for cartopy. - Fixes bug in warning code when used in an embedded context. - Fixes crash when using Tk and closing the first open window before showing it - Many documentation improvements. - Restore a corner case on ColorBar tick usage. - Change the default behavior of `matplotlib.use` to silently allow more 'safe' switching after auto-discovery, but before starting an event loop. - Improvements to bounding box calculations. - Provide the correct length for RcParams instances. Wheels and packages on the conda-forge are available and the docs should be available (modulo caching issues). Thank you to everyone who worked on this! Tom -- Thomas Caswell tcaswell at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From navajyoth at iiserb.ac.in Tue Nov 27 02:42:18 2018 From: navajyoth at iiserb.ac.in (navajyoth814) Date: Tue, 27 Nov 2018 00:42:18 -0700 (MST) Subject: [Matplotlib-users] How to overcome the hatchings getting cut in contour plots? Message-ID: <1543304538817-0.post@n5.nabble.com> I have been using hatchings (dots) on top of contour plots. Tjese dots are getting cut at some places. How do I get rid of this? Please have a look at the image to see the error. -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From ben.v.root at gmail.com Tue Nov 27 10:00:36 2018 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 27 Nov 2018 10:00:36 -0500 Subject: [Matplotlib-users] How to overcome the hatchings getting cut in contour plots? In-Reply-To: <1543304538817-0.post@n5.nabble.com> References: <1543304538817-0.post@n5.nabble.com> Message-ID: The hatchings are clipped to the polygon or patch object they reside within. Therefore, you can't prevent cutting off some of the hatching because they need to be bounded somewhere. Now, you can change the density of a hatch if that helps, by repeating the character you used for your hatch. Ben Root On Tue, Nov 27, 2018 at 2:42 AM navajyoth814 via Matplotlib-users < matplotlib-users at python.org> wrote: > < > http://matplotlib.1069221.n5.nabble.com/file/t5196/Screenshot_20181127-131006.png> > > > > I have been using hatchings (dots) on top of contour plots. Tjese dots are > getting cut at some places. How do I get rid of this? > > Please have a look at the image to see the error. > > > > -- > Sent from: > http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html > _______________________________________________ > 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 zxs.201 at gmail.com Tue Nov 27 16:05:01 2018 From: zxs.201 at gmail.com (Xiaosong Zhu) Date: Tue, 27 Nov 2018 22:05:01 +0100 Subject: [Matplotlib-users] (no subject) Message-ID: <5bfdb17b.1c69fb81.87856.37f6@mx.google.com> Hi Everyone! May I ask a question. Is it possible to plot the 3D iso-surface figures? Like the figures plotted by isosurface in MATLAB? https://www.mathworks.com/help/matlab/ref/isosurface.html Or like the 1st figure in https://en.wikipedia.org/wiki/Atomic_orbital. I need this because I would like to plot the configure of target molecular orbitals using the data calculated from first-principle calculation. I have looked through the examples of the website. There are only examples similar to this but not the same? Thanks very much! Sincerely, Xiaosong -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.v.root at gmail.com Tue Nov 27 16:19:47 2018 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 27 Nov 2018 16:19:47 -0500 Subject: [Matplotlib-users] (no subject) In-Reply-To: <5bfdb17b.1c69fb81.87856.37f6@mx.google.com> References: <5bfdb17b.1c69fb81.87856.37f6@mx.google.com> Message-ID: plot_surface() in mplot3d can ultimately do what you want, but you need to provide it the isosurface. I think scikit-image can provide that information with its marching cubes function. Does that help? Ben Root On Tue, Nov 27, 2018 at 4:05 PM Xiaosong Zhu wrote: > Hi Everyone! > > > > May I ask a question. Is it possible to plot the 3D iso-surface figures? > Like the figures plotted by isosurface in MATLAB? > > > > https://www.mathworks.com/help/matlab/ref/isosurface.html > > > > Or like the 1st figure in > > > > https://en.wikipedia.org/wiki/Atomic_orbital. > > > > I need this because I would like to plot the configure of target molecular > orbitals using the data calculated from first-principle calculation. I have > looked through the examples of the website. There are only examples similar > to this but not the same? > > > > Thanks very much! > > > > Sincerely, > > Xiaosong > _______________________________________________ > 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 zxs.201 at gmail.com Tue Nov 27 16:34:57 2018 From: zxs.201 at gmail.com (Xiaosong Zhu) Date: Tue, 27 Nov 2018 22:34:57 +0100 Subject: [Matplotlib-users] (no subject) In-Reply-To: References: <5bfdb17b.1c69fb81.87856.37f6@mx.google.com> Message-ID: <5bfdb880.1c69fb81.60b43.36c2@mx.google.com> Dear Ben, Thank you very much! I guess so and I will check that! I previously saw some examples but thought colour could only be the same at the same height. But this may not be true. The cubes may be also helpful! Thank you very much for your help! Sincerely, Xiaosong ???: Benjamin Root ????: 2018?11?27? 22:20 ???: zxs.201 at gmail.com ??: Matplotlib-users ??: Re: [Matplotlib-users] (no subject) plot_surface() in mplot3d can ultimately do what you want, but you need to provide it the isosurface. I think scikit-image can provide that information with its marching cubes function. Does that help? Ben Root On Tue, Nov 27, 2018 at 4:05 PM Xiaosong Zhu wrote: Hi Everyone! ? May I ask a question. Is it possible to plot the 3D iso-surface figures? Like the figures plotted by isosurface in MATLAB? ? https://www.mathworks.com/help/matlab/ref/isosurface.html ? Or like the 1st figure in ? https://en.wikipedia.org/wiki/Atomic_orbital. ? I need this because I would like to plot the configure of target molecular orbitals using the data calculated from first-principle calculation. I have looked through the examples of the website. There are only examples similar to this but not the same? ? Thanks very much! ? Sincerely, Xiaosong _______________________________________________ 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 Tue Nov 27 16:50:06 2018 From: ben.v.root at gmail.com (Benjamin Root) Date: Tue, 27 Nov 2018 16:50:06 -0500 Subject: [Matplotlib-users] (no subject) In-Reply-To: <5bfdb880.1c69fb81.60b43.36c2@mx.google.com> References: <5bfdb17b.1c69fb81.87856.37f6@mx.google.com> <5bfdb880.1c69fb81.60b43.36c2@mx.google.com> Message-ID: The default settings for plot_surface() yields an surface with the same color. There are multiple ways to color the surface, either by supplying color information yourself via "facecolors", or turning on the "shade", and/or providing a "lightsource" object for custom shading. Unfortunately, the docs are pretty sparse in this area, but hopefully this will help. https://matplotlib.org/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.html#mpl_toolkits.mplot3d.axes3d.Axes3D.plot_surface There are some examples of using some of these keyword arguments here: https://matplotlib.org/examples/mplot3d/index.html Ben Root On Tue, Nov 27, 2018 at 4:34 PM Xiaosong Zhu wrote: > Dear Ben, > > > > Thank you very much! I guess so and I will check that! I previously saw > some examples but thought colour could only be the same at the same height. > But this may not be true. The cubes may be also helpful! > > > > Thank you very much for your help! > > > > Sincerely, > > Xiaosong > > > > *???: *Benjamin Root > *????: *2018?11?27? 22:20 > *???: *zxs.201 at gmail.com > *??: *Matplotlib-users > *??: *Re: [Matplotlib-users] (no subject) > > > > plot_surface() in mplot3d can ultimately do what you want, but you need to > provide it the isosurface. I think scikit-image can provide that > information with its marching cubes function. > > > > Does that help? > > > > Ben Root > > > > > > On Tue, Nov 27, 2018 at 4:05 PM Xiaosong Zhu wrote: > > Hi Everyone! > > > > May I ask a question. Is it possible to plot the 3D iso-surface figures? > Like the figures plotted by isosurface in MATLAB? > > > > https://www.mathworks.com/help/matlab/ref/isosurface.html > > > > Or like the 1st figure in > > > > https://en.wikipedia.org/wiki/Atomic_orbital. > > > > I need this because I would like to plot the configure of target molecular > orbitals using the data calculated from first-principle calculation. I have > looked through the examples of the website. There are only examples similar > to this but not the same? > > > > Thanks very much! > > > > Sincerely, > > Xiaosong > > _______________________________________________ > 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 zxs.201 at gmail.com Tue Nov 27 17:21:28 2018 From: zxs.201 at gmail.com (Xiaosong Zhu) Date: Tue, 27 Nov 2018 23:21:28 +0100 Subject: [Matplotlib-users] (no subject) In-Reply-To: References: <5bfdb17b.1c69fb81.87856.37f6@mx.google.com> <5bfdb880.1c69fb81.60b43.36c2@mx.google.com> Message-ID: <5bfdc367.1c69fb81.ac2e.39c8@mx.google.com> Dear Ben, Thank you very much! Now that I know it is possible, I will carefully read the manual and solve the problem! Sincerely, Xiaosong ???: Benjamin Root ????: 2018?11?27? 22:50 ???: zxs.201 at gmail.com ??: Matplotlib-users ??: Re: [Matplotlib-users] (no subject) The default settings for plot_surface() yields an surface with the same color. There are multiple ways to color the surface, either by supplying color information yourself via "facecolors", or turning on the "shade", and/or providing a "lightsource" object for custom shading. Unfortunately, the docs are pretty sparse in this area, but hopefully this will help. https://matplotlib.org/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.html#mpl_toolkits.mplot3d.axes3d.Axes3D.plot_surface There are some examples of using some of these keyword arguments here: https://matplotlib.org/examples/mplot3d/index.html Ben Root On Tue, Nov 27, 2018 at 4:34 PM Xiaosong Zhu wrote: Dear Ben, ? Thank you very much! I guess so and I will check that! I previously saw some examples but thought colour could only be the same at the same height. But this may not be true. The cubes may be also helpful! ? Thank you very much for your help! ? Sincerely, Xiaosong ? ???: Benjamin Root ????: 2018?11?27? 22:20 ???: zxs.201 at gmail.com ??: Matplotlib-users ??: Re: [Matplotlib-users] (no subject) ? plot_surface() in mplot3d can ultimately do what you want, but you need to provide it the isosurface. I think scikit-image can provide that information with its marching cubes function. ? Does that help? ? Ben Root ? ? On Tue, Nov 27, 2018 at 4:05 PM Xiaosong Zhu wrote: Hi Everyone! ? May I ask a question. Is it possible to plot the 3D iso-surface figures? Like the figures plotted by isosurface in MATLAB? ? https://www.mathworks.com/help/matlab/ref/isosurface.html ? Or like the 1st figure in ? https://en.wikipedia.org/wiki/Atomic_orbital. ? I need this because I would like to plot the configure of target molecular orbitals using the data calculated from first-principle calculation. I have looked through the examples of the website. There are only examples similar to this but not the same? ? Thanks very much! ? Sincerely, Xiaosong _______________________________________________ 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: