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






Showing 7 results of 7

From: Mark B. <mar...@gm...> - 2012年09月05日 23:19:31
Hi,
I'm not an expert so please go easy on me. I am using the pyplot lasso
demo, and have got it to work how I would like. I am having a problem,
however, where I cannot get it to work if my python file is not the
main file (where __name__ is not __main__).
I took the part at the bottom in the "if __name__ == '__main__':" and
put it into a class. Everything works fine if I call the class from
within the same file. However, if I call the class from another file,
the graph loads fine but the lasso tool does not work. Troubleshooting
revealed that LassoManager.onpress is not being called when I click
the mouse. Any suggestions are welcome because this is driving me
crazy!
Thanks,
Mark
From: Sterling S. <sm...@fu...> - 2012年09月05日 16:39:41
On Sep 4, 2012, at 5:33PM, Jae-Joon Lee wrote:
> On Wed, Sep 5, 2012 at 6:05 AM, Sterling Smith <sm...@fu...> wrote:
>> I still do not get black markers. Furthermore, if you try to make a new legend with the result of leg.get_lines(), you will get lines without markers, which leads me to the conclusion I stated in my previous email (which you did not copy)
>>>> I suspect that this is because the legend marker is drawn separately from the legend line to accommodate the numpoints argument of the legend functions. Then the question is how to access these markers if they are separate from the line2d objects in the legend. I didn't even see them in the children of the legend [legend.get_children()].
> 
> This is correct. To support legend handle like --o-- (i.e., no markers
> at the ends), lines and markers are drawn as a separate artist. You
> may use something like,
> 
> line[0]._legmarker.set_markerfacecolor('black')
> line[1]._legmarker.set_markerfacecolor('black')
> 
> I, personally, recommend you to use a proxy artist.
> 
> http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
> 
> For example,
> 
> You may do something like
> 
> import pylab
> pylab.plot(pylab.linspace(0,1,100),marker='o',ls='')
> pylab.plot(pylab.linspace(0,1,100),marker='o',ls='-')
> 
> # creates artists for legend purpose only
> l1, = pylab.plot(pylab.linspace(0,1,100), 'ko-')
> l2, = pylab.plot(pylab.linspace(0,1,100), 'ko')
> # remove them from the axes.
> l1.remove()
> l2.remove()
> 
> leg=pylab.legend([l1, l2], ["Test 1", "Test 2"], loc='best')
> 
> Regards,
> 
> -JJ
JJ,
Thank you for responding. I was looking for the _legmarker method, which works great.
Thanks,
Sterling
From: Jae-Joon L. <lee...@gm...> - 2012年09月05日 07:09:02
Attachments: rrer.py
There is no easy way to do it (the extent of axes including the labels
is determined only when the plot is drawn).
And most straight forward way is to define your own artist.
Attached is an one example of such artist. I think it is good to have
such an artist class in matplotlib and I may able to push some
generalized version of this into matplotlib.
On the other hand, your reason to draw a white box is to improve the
visibility of tick labels, I recommend you to use path_effect.
from matplotlib.patheffects import withStroke
plt.setp(axins1.xaxis.get_majorticklabels(),
 path_effects=[withStroke(foreground="w", linewidth=3)])
IHTH,
-JJ
On Thu, Aug 16, 2012 at 12:39 AM, Scott Henderson <st...@co...> wrote:
> Hello,
>
> I'm trying to modify the following script to no avail:
> http://matplotlib.github.com/examples/axes_grid/demo_colorbar_with_inset_locator.html
>
> I'd like to have a white background behind the inset colorbar that
> adjusts automatically to figure resizing. I'm thinking of doing this by
> adding a Rectangle patch with the appropriate axes coordinates. What's
> the easiest way get those coordinates (sufficiently big to include the
> ticklabels) & draw the patch?
>
> Thanks,
>
> --
> ---------------
> Scott T. Henderson
> http://www.geo.cornell.edu/eas/gstudent/sth54/contact.html
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Jae-Joon L. <lee...@gm...> - 2012年09月05日 05:58:52
On Sun, Aug 19, 2012 at 3:41 PM, Peter Combs <pco...@gm...> wrote:
> It seems like draw()ing the text object will reset the size of the BBox...
> Any idea how to fix this? At the moment, I'm experimenting with continually
> drawing, polling the get_width() method, and when it's too small, adding in
> spaces around the text field, but that seems both not to work reliably, and
> be an incredibly boneheaded way to go about it.
>
> I'm using matplotlib v. 1.1.0 if that makes a difference.
>
>
> --------------\
> | text >
> --------------/
> not
> ------\
> | text >
> ------/
A recommended way of doing this is to make a custom BoxStyle,
from matplotlib.patches import BoxStyle
class MyRArrow(BoxStyle.RArrow):
 def transmute(self, x0, y0, width, height, mutation_size):
 # mutation_size is a fontsize in pixel scale.
 total_width = mutation_size*10
 dw = (total_width-width)*.5
 p = BoxStyle.RArrow.transmute(self, x0-dw, y0, total_width, height,
 mutation_size)
 return p
ax = subplot(111)
txtobj = ax.text(0.5, 0.5, 'text', ha="center",
 bbox=dict(boxstyle=MyRArrow()))
txtobj = ax.text(0.5, 0.3, 'long text', ha="center",
 bbox=dict(boxstyle=MyRArrow()))
However, BoxStyle does not know of the axes/figure/renderer, i.e., you
cannot make its width to some fraction of figure width, for example.
If this is what you want, you may need to derive from FancyBboxPatch
as Daniel Hyams suggested.
Regards,
-JJ
From: Jae-Joon L. <lee...@gm...> - 2012年09月05日 05:35:46
On Mon, Aug 20, 2012 at 10:50 PM, darkside <in....@gm...> wrote:
> I am using zoomed_inset_axes, but the default position overlaps the yticks
> and the parent axe ticks, so I am trying:
> axins = zoomed_inset_axes(ax,
> 3,bbox_to_anchor(0.5,1),bbox_transform=ax.figure.transFigure, loc=2)
This is supposed to work, and my quick test did work. Can you post a
complete but simple exampl?
Regards,
-JJ
From: Jae-Joon L. <lee...@gm...> - 2012年09月05日 05:27:53
I recommend you to use LineCollection as it is rasterized as a single image.
For example,
from matplotlib.collections import LineCollection
d = [np.array([ts[0], ys1]).T for ys1 in ys]
lc = LineCollection(d, color='r', lw=0.5, alpha=0.5,
 rasterized=True)
ax.add_collection(lc)
ax.set_xlim(0, 7)
ax.set_ylim(-1, 1)
If you need to stick to plot command somehow, you need to create your
own artist.
There is a similar example,
http://matplotlib.sourceforge.net/examples/pylab_examples/demo_agg_filter.html
Take a look at the FilteredArtistList class. Your draw method should
be something like
 def draw(self, renderer):
 renderer.start_rasterizing()
 for a in self._artist_list:
 a.draw(renderer)
 renderer.stop_rasterizing()
IHTH,
-JJ
On Wed, Aug 22, 2012 at 2:45 AM, Peter St. John <pet...@gm...> wrote:
> Hi Everyone,
>
> I'm having problems when rasterizing many lines in a plot using the
> rasterized=True keyword using the pdf output.
> Some version info:
> matplotlib version 1.1.1rc
> ubuntu 12.04
> python 2.7.3
>
>
> Here's a basic example that demonstrates my problem:
> # Import matplotlib to create a pdf document
> import matplotlib
> matplotlib.use('Agg')
> from matplotlib.backends.backend_pdf import PdfPages
> pdf = PdfPages('rasterized_test.pdf')
>
> import matplotlib.pylab as plt
>
> # some test data
> import numpy as np
> ts = np.linspace(0,2*np.pi,100) * np.ones((200,100))
> ts += (np.linspace(0, np.pi, 200)[np.newaxis] * np.ones((100,200))).T
> ys = np.sin(ts)
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.plot(ts[0], ys.T, color='r', lw=0.5, alpha=0.5, rasterized=True)
> pdf.savefig()
>
> pdf.close()
>
>
>
> Essentially, I have a lot (200 in this case) of closely overlapping lines
> which makes the resulting figure (not rasterized) overly difficult to load.
> I would like to rasterize these lines, such that the axis labels (and other
> elements of the plot, not shown) remain vectors while the solution
> trajectories are flattened to a single raster background. However, using the
> code above, the image still takes a long time to load since each trajectory
> is independently rasterized, resulting in multiple layers. (If I open the
> resulting pdf with a program like inkscape, I can manipulate each trajectory
> independently.)
>
> Is it possible to flatten all of the rasterized elements into a single
> layer, so the pdf size would be greatly reduced?
>
> Thanks,
> --Peter
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2012年09月05日 00:33:57
On Wed, Sep 5, 2012 at 6:05 AM, Sterling Smith <sm...@fu...> wrote:
> I still do not get black markers. Furthermore, if you try to make a new legend with the result of leg.get_lines(), you will get lines without markers, which leads me to the conclusion I stated in my previous email (which you did not copy)
>>> I suspect that this is because the legend marker is drawn separately from the legend line to accommodate the numpoints argument of the legend functions. Then the question is how to access these markers if they are separate from the line2d objects in the legend. I didn't even see them in the children of the legend [legend.get_children()].
This is correct. To support legend handle like --o-- (i.e., no markers
at the ends), lines and markers are drawn as a separate artist. You
may use something like,
line[0]._legmarker.set_markerfacecolor('black')
line[1]._legmarker.set_markerfacecolor('black')
I, personally, recommend you to use a proxy artist.
http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
For example,
You may do something like
import pylab
pylab.plot(pylab.linspace(0,1,100),marker='o',ls='')
pylab.plot(pylab.linspace(0,1,100),marker='o',ls='-')
# creates artists for legend purpose only
l1, = pylab.plot(pylab.linspace(0,1,100), 'ko-')
l2, = pylab.plot(pylab.linspace(0,1,100), 'ko')
# remove them from the axes.
l1.remove()
l2.remove()
leg=pylab.legend([l1, l2], ["Test 1", "Test 2"], loc='best')
Regards,
-JJ

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 によって変換されたページ (->オリジナル) /