SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S




1
(17)
2
(3)
3
(2)
4
(11)
5
(8)
6
(22)
7
(16)
8
(9)
9
(14)
10
(1)
11
(8)
12
(5)
13
(7)
14
(10)
15
(28)
16
(8)
17
(20)
18
(6)
19
(5)
20
(15)
21
(8)
22
(7)
23
(14)
24
(10)
25
(6)
26
(8)
27
(9)
28
(11)
29
(13)
30
(20)

Showing 7 results of 7

From: Eric F. <ef...@ha...> - 2011年09月05日 23:57:14
On 09/05/2011 08:29 AM, José Alexandre Nalon wrote:
> Hello,
>
> Em 01/09/2011, às 00:16, Eric Firing escreveu:
>
>> On 08/31/2011 01:15 PM, José Alexandre Nalon wrote:
>>> Hello,
>>>
>>> some weeks ago, I recompiled matplotlib to get locale support for
>>> commas, <...>
>>
>> This is coming from CXX.
>>
>> I am not going to be able to figure out what the problem is, but those
>> who are (the C++ wizards) will probably want to see the full stack
>> trace, as well as the matplotlib version and the compilation parameters:
>> platform, compiler, python version, etc. The first part of the output
>> from setup.py build has all that.
>
> Sorry for taking so long to answer. I was installing Linux on
> a new laptop, and, as I thought would happen, I could install
> the newest matplotlib, and it is running without any errors
> now. As I suspected, it was something in my configuration, I
> don't know, however, what it could be.
>
> I apologize for raising an alarm, though. At first, I was under
> the impression that that bug could affect more than one person.
> Glad to see everything working fine.
Thanks for the update, and I'm glad you got it working.
Eric
>
> ---
> José Alexandre Nalon
> na...@te... <mailto:na...@te...>
From: Hans B. <han...@ar...> - 2011年09月05日 19:29:27
Hi Matt,
a possible workaround seems to be to embed the figure's canvas in a second 
Tk canvas using canvas.create_window(...). The second (embedding) canvas 
handles the appropriate resizing & scrolling. I have attached a script 
below to demonstrate. Unfortunately, scrolling is rather sluggish, but it 
seems to work - the plot is not resized, and you can scroll around to 
different areas. Does that help?
Cheers
Hans
On 2011年8月31日 22:19:26 +0200, Benjamin Root <ben...@ou...> wrote:
> On Wed, Aug 31, 2011 at 2:55 PM, Matthew Hemke <mg...@gm...> wrote:
>
>> I have a plot canvas added to a tk interface (python 2.7.2, matplotlib
>> 1.0.1) according to the recipe here:
>>
>>
>> http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_tk.html
>>
>> When the window containing the plot is resized the plot shrinks, often
>> leading to REALLY ugly, unreadable plots.
>>
>> I tried adding scrollbars to the canvas returned by get_tk_widget() and
>> they connect as expected (using the yview method). Then, I set a 
>> scrollarea
>> config option for the canvas.
>>
>> Everything seems to be working just like a tkinter canvas, but then when
>> the window is resized, the plot still resizes and the scrollbars never
>> activate. I was hoping the plot wouldn't resize and the scrollbars would
>> activate to allow the user to scroll to see the appropriate part of the
>> plot, while still keeping the plot looking pretty.
>>
>> Is there a way (besides editing backend_tkagg.py self.resize method) 
>> that
>> would allow the scrollbars to work properly?
>>
>> If my question isn't clear, I can mock up some code, but it may be a bit
>> lengthy, so if anyone can steer me in a better direction that would be
>> great.
>>
>> Thanks,
>>
>> -Matt
>>
--- start of script ---
 from Tkinter import Tk, Frame, Canvas, Scrollbar
 from Tkconstants import NSEW, HORIZONTAL, EW, NS, ALL
 from matplotlib import pyplot as plt
 from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
def doLargePlot():
 from numpy.random import randn
 matrix = randn(100, 100)
 plt.pcolor(matrix)
def getScrollingCanvas(frame):
 """
 Adds a new canvas with scroll bars to the argument frame
 NB: uses grid layout
 @return: the newly created canvas
 """
 frame.grid(sticky=NSEW)
 frame.rowconfigure(0, weight=1)
 frame.columnconfigure(0, weight=1)
 canvas = Canvas(frame)
 canvas.grid(row=0, column=0, sticky=NSEW)
 xScrollbar = Scrollbar(frame, orient=HORIZONTAL)
 yScrollbar = Scrollbar(frame)
 xScrollbar.grid(row=1, column=0, sticky=EW)
 yScrollbar.grid(row=0, column=1, sticky=NS)
 canvas.config(xscrollcommand=xScrollbar.set)
 xScrollbar.config(command=canvas.xview)
 canvas.config(yscrollcommand=yScrollbar.set)
 yScrollbar.config(command=canvas.yview)
 return canvas
if __name__ == "__main__":
 root = Tk()
 root.rowconfigure(0, weight=1)
 root.columnconfigure(0, weight=1)
 frame = Frame(root)
 scrollC = getScrollingCanvas(frame)
 # use more dpi for bigger plot
 #figure = plt.figure(dpi=200)
 figure = plt.figure()
 mplCanvas = FigureCanvasTkAgg(figure, scrollC)
 canvas = mplCanvas.get_tk_widget()
 canvas.grid(sticky=NSEW)
 scrollC.create_window(0, 0, window=canvas)
 scrollC.config(scrollregion=scrollC.bbox(ALL))
 doLargePlot()
 root.mainloop()
--- end of script ---
From: Jeffrey S. <jef...@gm...> - 2011年09月05日 18:15:22
You can use dpi=600 as a parameter to increase the resolution but I'm 
not sure if that's what you mean. If you mean the actual compression 
strategy used like to Jpeg2000 per se. Might have to do that after 
saving the file with an image library (for example, PIL).
Cheers,
Jeff
On 09/06/2011 03:21 AM, Frank Breitling wrote:
> Hi,
>
> I am using matplotlib.savefig to save my figures as JPEG files.
> Now I need to reduce the JPG compression ratio.
> How can I do this?
>
> Any hint is appreciated.
>
> Frank
>
> ------------------------------------------------------------------------------
> Special Offer -- Download ArcSight Logger for FREE!
> Finally, a world-class log management solution at an even better
> price-free! And you'll get a free "Love Thy Logs" t-shirt when you
> download Logger. Secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsisghtdev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Frank B. <fbr...@ai...> - 2011年09月05日 17:48:56
Hi,
I am using matplotlib.savefig to save my figures as JPEG files.
Now I need to reduce the JPG compression ratio.
How can I do this?
Any hint is appreciated.
Frank
From: Lynn O. <ray...@gm...> - 2011年09月05日 06:46:56
I don't know about changing backends, but I do need to use TkAgg.
I finally got it working. The instructions from the original email below are what worked, but first I had to uninstall Tcl8.6 (manually). The first time I tried it I deleted something that I shouldn't have, and ended up with a mess that I cleaned up by doing a full erase/reinstall of Lion. Then I restored the system from a backup, carefully removed Tcl8.6 manually (the uninstall script is broken), removed most of the remnants of macports, reinstalled a few things that were broken by the reinstall of Lion (XCode, XQuartz, WingIDE, TextWrangler), uninstalled and reinstalled Python 2.7.2, reinstalled Tcl8.5, and rebuilt matplotlib per the instructions.
Hopefully it will go much smoother when I set up the new system in a few days.
Thanks for your help...
Lynn
On Sep 4, 2011, at 12:55 AM, Michiel de Hoon wrote:
> What happens if you use the MacOSX backend instead of TkAgg? Or do you have to use TkAgg?
> 
> --Michiel.
> 
> --- On Sun, 9/4/11, Lynn Oliver <ray...@gm...> wrote:
> 
> From: Lynn Oliver <ray...@gm...>
> Subject: Re: [Matplotlib-users] problems installing matplotlib on OS X Lion
> To: "Bryan K Woods" <bw...@ae...>
> Cc: "mat...@li..." <mat...@li...>
> Date: Sunday, September 4, 2011, 3:38 AM
> 
> Bryan, thanks for the response.
> 
> I installed macports and the environment settings seem to be correct, but when I try "port help selfupdate" I get:
> /opt/local/bin/port: line 4: /usr/bin/tclsh: No such file or directory
> /opt/local/bin/port: line 4: exec: /usr/bin/tclsh: cannot execute: No such file or directory
> 
> I removed the installation of Tcl 8.6 and reinstalled ActiveTcl 8.5.10, but still get the same warnings. 
> 
> Matplotlib is now complaining about the missing Tcl8.6:
> 
> ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/_tkagg.so, 2): Library not loaded: /Library/Frameworks/Tcl.framework/Versions/8.6/Tcl. 
> 
> I am assuming that your unsuccessful install via macports was after you had macports working; do you know what version of Tcl was installed?
> 
> Macports fails with the same warnings after putting a link to tclsh8.5 in /usr/bin/tchsh.
> 
> I still seem to be running in circles.
> 
> Lynn
> 
> 
> 
> 
> On Sep 3, 2011, at 10:46 PM, Bryan K Woods wrote:
> 
>> I had a problem getting with Lion as well. I was able to work around it by:
>> 1) unsuccessfully trying to install matplotlib for python 2.7 via macports
>> 2) then using easy_install to install matplotlib
>> 
>> Bryan K. Woods, Ph.D.
>> Staff Scientist
>> Atmospheric & Environmental Research, Inc.
>> bw...@ae...
>> 
>> On Sep 4, 2011, at 1:06 AM, Lynn Oliver <ray...@gm...> wrote:
>> 
>>> After many unsuccessful attempts at getting matplotlib installed on OS X Lion, I ran across this page:
>>> Installing Matplotlib on OS X 10.7 with Homebrew « Random Musings for the Digital Age
>>> 
>>> Following these instructions got me the closest I have been:
>>> 
>>> $ brew install python
>>> $ brew install gfortran
>>> $ brew install pkg-config
>>> $ easy_install pip
>>> $ pip install numpy
>>> $ cd $HOME
>>> $ git clone https://github.com/matplotlib/matplotlib.git
>>> $ cd matplotlib
>>> $ python setup.py build
>>> $ python setup.py install
>>> 
>>> At the moment, I'm trying to get a script that was working on EPD 7.1 to work on Python 2.7.2. I'm using the TkAgg backend.
>>> 
>>> The first messages I see when running the script are:
>>> 
>>> objc[68962]: Class TKApplication is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
>>> objc[68962]: Class TKMenu is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
>>> objc[68962]: Class TKContentView is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
>>> objc[68962]: Class TKWindow is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /Library/Frameworks/Tk.framework/Versions/8.6/Tk. One of the two will be used. Which one is undefined.
>>> 
>>> For both Tk and Tcl, ../Versions/Current points to 8.6. 
>>> 
>>> From there, everything is fine until it executes show(), when I get the following messages:
>>> 
>>> Exception in Tkinter callback
>>> Traceback (most recent call last):
>>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1410, in __call__
>>> return self.func(*args)
>>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 236, in resize
>>> self.show()
>>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 240, in draw
>>> tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
>>> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/tkagg.py", line 19, in blit
>>> tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))
>>> TclError
>>> 
>>> Can anyone suggest how to resolve this problem?
>>> 
>>> Thanks,
>>> Lynn
>>> ------------------------------------------------------------------------------
>>> Special Offer -- Download ArcSight Logger for FREE!
>>> Finally, a world-class log management solution at an even better 
>>> price-free! And you'll get a free "Love Thy Logs" t-shirt when you
>>> download Logger. Secure your free ArcSight Logger TODAY!
>>> http://p.sf.net/sfu/arcsisghtdev2dev
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
> -----Inline Attachment Follows-----
> 
> ------------------------------------------------------------------------------
> Special Offer -- Download ArcSight Logger for FREE!
> Finally, a world-class log management solution at an even better 
> price-free! And you'll get a free "Love Thy Logs" t-shirt when you
> download Logger. Secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsisghtdev2dev
> 
> -----Inline Attachment Follows-----
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Ryan N. <rne...@gm...> - 2011年09月05日 04:27:00
Hello all,
I noticed some unusual behavior with specific combinations of axes.twinx and
pyplot.xticks. It seems that under certain conditions, the pyplot.xticks
command can cause an x offset of the plots. Here's a relatively short
example (as written, this works fine):
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-np.pi, np.pi, 1000)
fig = plt.figure()
ax1 = plt.axes()
ax1.plot(x, np.sin(x)+1)
plt.ylim(-1,2)
ax2 = ax1.twinx()
ax2.plot(x, np.sin(x) )
plt.ylim(-1,2)
plt.xlim(-np.pi, np.pi)
ts = np.linspace(-1, 3, 5)
#ts = np.linspace(-1, 4, 5)
plt.xticks( ts, ['%.2f'%i for i in ts] )
plt.show()
However, if the comment on the 'ts' array creation code is reversed, the
second plot appears offset from the original.
I realize it is idiotic to put ticks outside the axis range, but this caused
some problems when I inadvertently did it once (or more...).
I've tried this with Matplotlib 1.0.1/Python 2.6.6 (Python x,y) on Windows 7
and Matplotlib 1.0.1/Python 2.7.1 on Gentoo Linux.
Thanks
Ryan
From: Ryan N. <rne...@gm...> - 2011年09月05日 03:49:37
Rob,
Have you tried the zorder argument. It is an integer that controls the
relative 'height' of a plotting element: higher numbers are plotted over
lower numbers. For example, the following code plots the scatter points on
top of the plotted line (even though scatter was called first):
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-1, 1, 10)
y = np.random.rand(10)
plt.scatter(x, y, s=50, zorder=2)
plt.plot(x, y, 'r', lw=2, zorder=1)
plt.show()
Also, looking over your code, I noticed you had a for loop for your plot
commands. The plot command can take two dimensional arrays for x and y as
well. In this case, the x and y data for each individual plot are the
columns of the 2D arrays. For your problem in particular, you may find
Numpy's 'tile' command to be useful as well. Here's some code that does
something similar to what you are doing (I think).
import numpy as np
import matplotlib.pyplot as plt
z = np.tile( range(5), (5,1) )
plt.plot(z, np.random.rand(5, 5), 'o')
plt.show()
This may not make a big difference in your code, but if you have a lot of
data, it may speed things up a little. (As I understand it, the Python for
loops can be a little slow.)
Hope this helps a little.
Ryan
Date: 2011年9月02日 14:18:39 -0230
> From: Rob Briggs <rdb...@mu...>
> Subject: [Matplotlib-users] order of plotting for 'layer' of data
> To: mat...@li...
> Message-ID: <1314982119.4902.118.camel@localhost.localdomain>
> Content-Type: text/plain; charset="us-ascii"
>
> Hello,
>
> I'm not sure of the correct way to ask this question.....I'm trying to
> create a plot that has a number of layers. I plot a standard plot, then
> a scatterplot over that. See attachment. I expected the scatter plot to
> 'render/draw' after the standard plot command, but the scatter plot data
> is buried under the standard command.
>
> I tried changing the order, i.e. scatterplot first but that had no
> effect. How do I ensure the scatterplot data is plotted above/over the
> other data?
>
> The following code extract is after all the data has been read and
> sorted.
>
> # start plotting
> plt.close()
>
> # first EAIS data
> stitle = 'plot showing cumulative paleoHmodel and paleoHscore for EAIS'
> # set up index range for plotting
> il=0 # index for lower bound to plot
> iu=idx_splt # index for upper bound to plot
>
> fig = plt.figure(5,figsize=(18,12))
> ax1 = fig.add_subplot(111)
> plt.title(stitle, fontsize=16)
> plt.xlabel("paleoH data point")
> plt.ylabel("thickness [m]")
>
> ii=np.empty(num_rows)
> # plot the model results
> for i in range(il,iu):
> ii[:] = i+1
> plt.plot(ii,a[:,i],'o',color='0.9')
>
> # set axis limits
> ymin=-1800
> ymin=-500
> ax1.set_xlim(il,iu+1)
> top = 3000
> bottom=-500
> ax1.set_ylim(bottom, top)
>
> # plot the labels
> for i in range(il,iu):
> plt.text(i+1,ymin,datn[i], horizontalalignment='center',
> fontsize=10,rotation='vertical', verticalalignment='bottom')
>
>
> #cmap = cm.get_cmap('PRGn', 10)
> #cmap = cm.get_cmap('autumn_r', 100)
> #cmap = cm.get_cmap('gray', 100)
>
> #plt.scatter(obs[il:iu,0],obs[il:iu,1],c=time[il:iu],marker='s',s=50,cmap=cmap)
> plt.scatter(obs[il:iu,0], obs[il:iu,1], c=time[il:iu],marker='s',s=100)
> plt.colorbar()
>
> # plot the observation dp with error bars
> #plt.errorbar(obs[il:iu,0], obs[il:iu,1], yerr=obs[il:iu,2], fmt='r.')
>
> plt.grid(which='both')
> fname="scoreVSpaleoHsite.png"
> plt.savefig(fname)
> plt.show()
>
>
> Regards
>
> Rob
>
>
> This electronic communication is governed by the terms and conditions at
> http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2011.php
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: scoreVSpaleoHsite.png
> Type: image/png
> Size: 223292 bytes
> Desc: not available
>
>
1 message has been excluded from this view by a project administrator.

Showing 7 results of 7

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /