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

Showing 6 results of 6

From: Daniel H. <dh...@gm...> - 2012年08月08日 23:23:16
Attachments: bigbogrot.png bigbox.png
I was wanting to allow the specification of the size of the box used to
enclose the text in an annotation, rather than allowing it to always fit
exactly to the text. I know that I could always just draw a rectangle, and
then text on top, but I was wanting to also be able to drag thing thing
around on the graph, in which case it is much more straightforward to keep
the text and rectangle together, just like the annotation does.
So my first attempt at drawing the box according to a set size looks like
the attached code: in text.py, I inserted some code into Text._draw_bbox().
 So long as the annotation has an attribute bbox_size that exists, it's
used for the size of the box. Very straightforward, *but* it doesn't
survive a text rotation like an annotation (see attached images). I have
no clue what I'm doing wrong, and I will also have to confess a lot of
ignorance when it comes to matplotlib's transforms, mutations, and such.
I've been fiddling with this for hours with no success, and it seems that
it should be simple :(
 def _draw_bbox(self, renderer, posx, posy):
 """ Update the location and the size of the bbox
 (FancyBoxPatch), and draw
 """
 x_box, y_box, w_box, h_box = _get_textbox(self, renderer)
 #======================my extra code ===============================
 # self._get_xy is annotation specific.
 # self.textcoords is annotation specific.
 x_box_orig,y_box_orig = x_box,y_box
 if getattr(self,'bbox_size',None):
 bx,by = self.bbox_size
 pt0 = self._get_xy(renderer,0.0,0.0,self.textcoords)
 pt1 = self._get_xy(renderer,bx,0.0,self.textcoords)
 pt2 = self._get_xy(renderer,0.0,by,self.textcoords)
 bx = pt1[0]-pt0[0]
 by = pt2[1]-pt0[1]
 xc = x_box + w_box/2
 yc = y_box + h_box/2
 x_box = xc - bx/2
 y_box = yc - by/2
 w_box = bx
 h_box = by
#================================================================================
 self._bbox_patch.set_bounds(0., 0.,
 w_box, h_box)
 theta = self.get_rotation()/180.*math.pi
 tr = mtransforms.Affine2D().rotate(theta)
 tr = tr.translate(posx+x_box, posy+y_box)
 self._bbox_patch.set_transform(tr)
 fontsize_in_pixel = renderer.points_to_pixels(self.get_size())
 self._bbox_patch.set_mutation_scale(fontsize_in_pixel)
 self._bbox_patch.draw(renderer)
-- 
Daniel Hyams
dh...@gm...
From: Warren W. <war...@en...> - 2012年08月08日 22:37:10
On Wed, Aug 8, 2012 at 3:34 PM, Gustavo Goretkin <gus...@gm...
> wrote:
> I can use the scatter function to plot an array of points and give a
> corresponding array of colors to set those points. Is it possible to
> do the same thing with alpha values?
>
> Right now, I'm restoring to calling plot with an 'o' marker for each
> individual point, which is slow.
>
>
The 'color' argument of the 'scatter' function can take an array of
(r,g,b,alpha) values:
In [23]: x = array([0, 1, 2, 3])
In [24]: y = array([0, 1, 1, 2])
In [25]: c = array([[0,0,1,1], [0,0,1,0.5], [0,1,0,0.5], [1,0,1,.9]])
In [26]: scatter(x, y, color=c)
Out[26]: <matplotlib.collections.PathCollection at 0x898adf0>
Warren
>
> ------------------------------------------------------------------------------
> 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: Damon M. <dam...@gm...> - 2012年08月08日 21:49:30
On Wed, Aug 08, 2012 at 05:22:49PM -0400, Tony Yu wrote:
> On Wed, Aug 8, 2012 at 4:34 PM, Gustavo Goretkin <gus...@gm...
> > wrote:
> 
> > I can use the scatter function to plot an array of points and give a
> > corresponding array of colors to set those points. Is it possible to
> > do the same thing with alpha values?
> >
> You can use a colormap with varying alpha values.
Would it be possible to do something like
ax.plot(x, y, color=[c1, c2, c3], alpha=[a1, a2, a3])?
It doesn't seem that it's supported and that would be the 'natural'
extension, in some sense.
-- 
Damon McDougall
http://damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom
From: Tony Yu <ts...@gm...> - 2012年08月08日 21:23:35
On Wed, Aug 8, 2012 at 4:34 PM, Gustavo Goretkin <gus...@gm...
> wrote:
> I can use the scatter function to plot an array of points and give a
> corresponding array of colors to set those points. Is it possible to
> do the same thing with alpha values?
>
> Right now, I'm restoring to calling plot with an 'o' marker for each
> individual point, which is slow.
>
>
You can use a colormap with varying alpha values.
Example below. I'm not a huge fan of the call signature of
`LinearSegmentedColormap`, so I've included a class that makes it a little
more convenient to define the colormap.
Cheers,
-Tony
P.S. There were some major cleanups of the alpha handling not too long ago,
but I don't think those are necessary for scatter. Let me know if this
doesn't work for some reason.
#~~~ example code
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
class LinearColormap(LinearSegmentedColormap):
 def __init__(self, name, segmented_data, index=None, **kwargs):
 if index is None:
 # If index not given, RGB colors are evenly-spaced in colormap.
 index = np.linspace(0, 1, len(segmented_data['red']))
 for key, value in segmented_data.iteritems():
 # Combine color index with color values.
 segmented_data[key] = zip(index, value)
 segmented_data = dict((key, [(x, y, y) for x, y in value])
 for key, value in segmented_data.iteritems())
 LinearSegmentedColormap.__init__(self, name, segmented_data,
**kwargs)
# Red for all values, but alpha changes linearly from 0.3 to 1
color_spec = {'blue': [0.0, 0.0],
 'green': [0.0, 0.0],
 'red': [0.8, 0.8],
 'alpha': [0.3, 1.0]}
alpha_red = LinearColormap('alpha_red', color_spec)
x, y, z = np.random.normal(size=(3, 100))
plt.scatter(x, y, c=z, cmap=alpha_red, s=50, edgecolors='none')
plt.show()
# Here's a slightly more complicated use of LinearColormap, if you're
interested.
# Blue below midpoint of colormap, red above mid point.
# Alpha maximum at the edges, minimum in the middle.
bwr_spec = {'blue': [0.4, 0.4, 0.1, 0.1],
 'green': [0.2, 0.2, 0.0, 0.0],
 'red': [0.02, 0.02, 0.4, 0.4],
 'alpha': [1, 0.3, 0.3, 1]}
blue_white_red = LinearColormap('blue_white_red', bwr_spec,
 index=[0, 0.5, 0.5, 1])
From: Gustavo G. <gus...@gm...> - 2012年08月08日 20:35:10
I can use the scatter function to plot an array of points and give a
corresponding array of colors to set those points. Is it possible to
do the same thing with alpha values?
Right now, I'm restoring to calling plot with an 'o' marker for each
individual point, which is slow.
From: darkside <in....@gm...> - 2012年08月08日 11:03:57
---------- Forwarded message ----------
From: darkside <in....@gm...>
Date: 2012年8月2日
Subject: Re: [Matplotlib-users] zoomed in detail box
To: Jae-Joon Lee <lee...@gm...>
Hi everyone!
I'm also trying to do a detailed zoomed area of my plot, but I can't manage
to put the box in the position I want, bbox_to_anchor didn't work in my
case:
axins =
zoomed_inset_axes(ax,3,loc=2,bbox_to_anchor=(0,0,0.5,0.5),bbox_transform=ax.transAxes)
This bbox_to_anchor tuple is just an example. I only want to move the
zoomed box a little to the right, since the ticklabels overlap.
Any idea?
I really appreciate your help!
2009年7月10日 Jae-Joon Lee <lee...@gm...>
> On Thu, Jul 9, 2009 at 7:24 AM, Robin<ro...@gm...> wrote:
> >> On Wed, Jul 8, 2009 at 10:57 PM, Jae-Joon Lee<lee...@gm...>
> wrote:
> >>> If you use the svn version of matplotlib, you may use axes_grid
> toolkit.
> >>>
> >>>
> http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#insetlocator
> >
> > Wow - this is really amazing. Sometimes it can be a bit frustrating
> > when I'm working to a deadline to figure out the details of Bbox's and
> > such but when I find something like this it really makes it worth
> > while! It does exactly what I want, really easy to use and only took
> > about 5 lines! (It would be nice if there were some docstrings in
> > there though :))
> >
> > On Thu, Jul 9, 2009 at 4:02 AM, Jae-Joon Lee<lee...@gm...>
> wrote:
> >> However, It is possible to specify the location of the axes in
> >> normalized axes coordinate.
> >>
> >> http://thread.gmane.org/gmane.comp.python.matplotlib.general/16373
> >
> > I'm afraid I didn't really understand how to apply this in my case...
> > I guess I would have to set the position and everything by hand
> > instead of using the zoom helper. I preferred to use the zoom helper,
> > but found the legend loc settings put it slightly too close to the
> > edge of the surrounding axes for my taste.
> >
> > So after checking the docstrings for how to position legends I came up
> > with something that works, but it required a minor change to the
> > inset_locator.py to pass the bbox_to_anchor and bbox_transform (it
> > looks like this was intended since they have None default values):
> >
> > robin-mbp-3:~ robince$ diff
> >
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/mpl_toolkits/axes_grid/inset_locator.py
> > code/scipy_build/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py
> > 288c288
> > < axes_locator = AnchoredZoomLocator(parent_axes, zoom=zoom,
> > loc=loc, bbox_to_anchor=bbox_to_anchor,bbox_transform=bbox_transform)
> > ---
> >> axes_locator = AnchoredZoomLocator(parent_axes, zoom=zoom, loc=loc)
> >
> > With this minor change I get exactly what I want!
> >
>
> Thanks for the catch. I'll commit the change to the svn soon.
> By the way, borderpad keyword is meant to do what you want. However, I
> just found that it does not work sine the option is not properly
> handled. I'll fix this in the next commit.
>
> Regards,
>
> -JJ
>
>
> > ax1ins = zoomed_inset_axes(ax1, 3,
> > bbox_to_anchor=(0.1,0,1,1),bbox_transform=ax1.transAxes, loc=6)
> > plot_trial_dists(res515[0],8,ax=ax1ins)
> > ax1ins.set_xlim([5, 50])
> > ax1ins.set_ylim([0, 0.04])
> > ax1ins.set_xticks([])
> > ax1ins.set_yticks([])
> > mark_inset(ax1, ax1ins, loc1=2, loc2=4, fc="none", ec="0.5")
> >
> > thanks again, this is really terrific!
> >
> > Cheers
> >
> > Robin
> >
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to 100,000ドル in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

Showing 6 results of 6

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