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




Showing 17 results of 17

From: John <was...@gm...> - 2010年11月03日 21:41:18
log Y axis?
On Wed, Nov 3, 2010 at 6:18 AM, David Frey <dp...@sh...> wrote:
> I am trying to use matplotlib (for the first time) to graph the address space
> usage of an application against time. The data is written to a log file by
> trace statements throughout the source code of the application. The trace
> statements contain the current address space usage as well as a timer value
> with millisecond granularity.
>
> My data in the y-axis (address space usage) is fairly uniform (0-2000 MB
> values), but my data in the x-axis (the time at which the the trace statements
> were executed) is highly clustered. For example, I have approximately 150
> data points over a 5 minute run, but some of the data points are only 10ms
> apart.
>
> I would like to annotate each point on the graph with the line number in the
> log file so that the user can look up what was happening at that point. I have
> succeeded, but the graph isn't readable because there is so much overlap in
> the points.
>
> Is there a standard way that people display data like this? I don't really
> like the idea of equally spacing all of the points along the x-axis because
> you lose the understanding of the timing. One idea I had was to have some
> sort of vertical break in the graph at areas where there was a long gap
> without a data point, but I have no idea whether it's possible to implement
> something like that in matplotlib.
>
> The output format hasn't been strictly specified, so if you have any ideas of
> how I can produce a useful graph, I would be happy to hear them.
>
> Thanks,
> Dave
>
> ------------------------------------------------------------------------------
> Achieve Improved Network Security with IP and DNS Reputation.
> Defend against bad network traffic, including botnets, malware,
> phishing sites, and compromised hosts - saving your company time,
> money, and embarrassment.  Learn More!
> http://p.sf.net/sfu/hpdev2dev-nov
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Configuration
``````````````````````````
Plone 2.5.3-final,
CMF-1.6.4,
Zope (Zope 2.9.7-final, python 2.4.4, linux2),
Python 2.6
PIL 1.1.6
Mailman 2.1.9
Postfix 2.4.5
Procmail v3.22 2001年09月10日
Basemap: 1.0
Matplotlib: 1.0.0
From: Eric F. <ef...@ha...> - 2010年11月03日 19:33:54
On 11/03/2010 09:01 AM, jgamble wrote:
>
> Hi all,
>
> I'm trying to visualize some data using countourf in pyplot, and I am having
> a bit of trouble. For some reason, the y axis does not scale properly, and
> an ugly white bar appears where there are no pixels to plot (see
> screenshot). Ideally, I would like the axes to scale so that there is no
> white space. The script I am using is:
>
> q=1.60219e-19
> kGrid = linspace(0.01,25e7,100)
> epsGrid = linspace(1e-10*q,0.13e-3*q,100)
> X,Y = meshgrid(kGrid,epsGrid)
> Z = abs(integrand(X,Y))
> CS = plt.contourf(X,Y/q/1000,Z,100,cmap=cm.PRGn)
Try following this with
plt.axis('tight')
Eric
>
> Here, "integrand" is just some function that generates z values. I imagine
> that it is something with aspect ratios or scaling, but I haven't been able
> to figure it out from reading posts, so I would greatly appreciate some
> guidance!
>
> Many thanks,
> John
>
> http://old.nabble.com/file/p30120592/Screen%2Bshot%2B2010-11-03%2Bat%2B2.56.03%2BAM.png
From: jgamble <joh...@gm...> - 2010年11月03日 19:01:52
Hi all,
I'm trying to visualize some data using countourf in pyplot, and I am having
a bit of trouble. For some reason, the y axis does not scale properly, and
an ugly white bar appears where there are no pixels to plot (see
screenshot). Ideally, I would like the axes to scale so that there is no
white space. The script I am using is:
q=1.60219e-19
kGrid = linspace(0.01,25e7,100)
epsGrid = linspace(1e-10*q,0.13e-3*q,100)
X,Y = meshgrid(kGrid,epsGrid)
Z = abs(integrand(X,Y))
CS = plt.contourf(X,Y/q/1000,Z,100,cmap=cm.PRGn)
Here, "integrand" is just some function that generates z values. I imagine
that it is something with aspect ratios or scaling, but I haven't been able
to figure it out from reading posts, so I would greatly appreciate some
guidance!
Many thanks,
John
http://old.nabble.com/file/p30120592/Screen%2Bshot%2B2010-11-03%2Bat%2B2.56.03%2BAM.png 
-- 
View this message in context: http://old.nabble.com/Unsightly-white-space-in-contour-plots-tp30120592p30120592.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Johan G. <joh...@gm...> - 2010年11月03日 18:54:49
2010年11月03日 19:26, Marcin Krol skrev:
> matplotlib:
> field.setCheckState(Qt.Checked if value else Qt.Unchecked)
> ^
> SyntaxError: invalid syntax
>
The code above is a conditional expression, and those are mentioned [0] 
on the "what's new in python 2.5"-page, so I would guess that line is 
invalid in python 2.4, that you use.
I would replace it by
if value:
 field.setCheckState(Qt.Checked)
else:
 field.setCheckedState(Qt.Unchecked)
and see if that particular error goes away.
There could of course be many similar issues, but I see that the system 
requirements lists python 2.4 or newer as required [1], so perhaps those 
constructs are often avoided.
In any case, if my guesses are correct, I would consider using the 
conditional expression in matplotlib as a bug, given that python 2.4 is 
mentioned in the requirements.
Regards
Johan
[0]: http://docs.python.org/whatsnew/2.5.html
[1]: http://matplotlib.sourceforge.net/users/installing.html
From: Marcin K. <mr...@gm...> - 2010年11月03日 18:27:03
Hello,
I've installed 1.0.0 on Python 2.4 (Debian Etch) and am getting just this:
Python 2.4.4 (#2, Jan 24 2010, 11:19:18)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import matplotlib.pyplot as plt
Illegal instruction
I've had some build problems with numpy 1.1 and matplotlib:
numpy:
Installed 
/usr/lib/python2.4/site-packages/numpy-1.5.1rc1-py2.4-linux-i686.egg
Processing dependencies for numpy
Finished processing dependencies for numpy
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
 File "atexit.py", line 24, in _run_exitfuncs
 func(*targs, **kargs)
 File 
"/tmp/easy_install-HPBq58/numpy-1.5.1rc1/numpy/distutils/misc_util.py", 
line 251, in clean_up_temporary_directory
ImportError: No module named numpy.distutils
Error in sys.exitfunc:
Traceback (most recent call last):
 File "/usr/lib/python2.4/atexit.py", line 24, in _run_exitfuncs
 func(*targs, **kargs)
 File 
"/tmp/easy_install-HPBq58/numpy-1.5.1rc1/numpy/distutils/misc_util.py", 
line 251, in clean_up_temporary_directory
ImportError: No module named numpy.distutils
orchidea 10.0.0.1 /usr/local/bin % easy_install numpy.distutils
Searching for numpy.distutils
matplotlib:
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for 
Ada/C/ObjC but not for C++
 File 
"build/bdist.linux-i686/egg/matplotlib/backends/qt4_editor/formlayout.py", 
line 275
 field.setCheckState(Qt.Checked if value else Qt.Unchecked)
 ^
SyntaxError: invalid syntax
But could this be the cause?
-- 
Regards,
mk
--
Premature optimization is the root of all fun.
From: Benjamin R. <ben...@ou...> - 2010年11月03日 14:32:42
On Wed, Nov 3, 2010 at 2:19 AM, Michiel de Hoon <mjl...@ya...> wrote:
> --- On *Tue, 11/2/10, Benjamin Root <ben...@ou...>* wrote:
>
> I have personally seen significant progress in this area, but there are a
> few backends that aren't quite right (MacOSX backend, I believe?).
>
> As far as I know, show() is working correctly in the MacOSX backend. If you
> encountered a case where the backend doesn't do the right thing, can you
> show a concrete example?
>
> Best,
> --Michiel.
>
>
>
Ah, so I must have been confused for something else. I don't use matplotlib
on a mac, so I don't know for sure. I just could have sworn there was a
conversation recently about issues in the macosx backend. I wonder which
backend it was that was still troublesome?
Ben Root
From: Anita G. <ani...@gm...> - 2010年11月03日 14:31:48
Hi,
I'm looking for a way to save Matplotlib figure objects the way Matlab can do it. I found the same request from 2008:
http://sourceforge.net/mailarchive/forum.php?thread_name=48D02DF2.2020401%40lanl.gov&forum_name=matplotlib-users
The answer basically was "There is currently no easy way".
Has the status changed since 2008?
Best wishes,
Anita
-- 
GMX DSL Doppel-Flat ab 19,99 &euro;/mtl.! Jetzt auch mit 
gratis Notebook-Flat! http://portal.gmx.net/de/go/dsl
From: Bartosz T. <b.t...@bi...> - 2010年11月03日 11:26:22
> 
> ax = plt.subplot(1,1,1)
> ticks = ax.xaxis.get_majorticklines()
> mytick = ticks[3]
> mytick.set_marker(2)
> plt.draw()
> 
Cool! That's what I have been looking for. Thanks so much for your help.
Regards,
Bartek
From: Michiel de H. <mjl...@ya...> - 2010年11月03日 07:20:05
--- On Tue, 11/2/10, Benjamin Root <ben...@ou...> wrote:
I
 have personally seen significant progress in this area, but there are a
 few backends that aren't quite right (MacOSX backend, I believe?).
As far as I know, show() is working correctly in the MacOSX backend. If you encountered a case where the backend doesn't do the right thing, can you show a concrete example?
Best,
--Michiel.
 
From: Eric F. <ef...@ha...> - 2010年11月03日 05:57:47
On 11/02/2010 03:18 PM, Jae-Joon Lee wrote:
> A quick (and not safe) way w/ mpl v1.0 is,
>
> ax = plt.subplot(111)
> ax.plot(np.arange(3))
>
> ax.set_xticks([0, 0.5, 1., 1.5, 2.])
>
> mytick = ax.xaxis.majorTicks[2]
> mytick._apply_params(tickdir="out")
>
> I don't think there is a way to do this only using public apis.
> I myself actually prefer to create a separate axis (or axes), but this
> will be more trickier than above solution.
Each tick is a Line2D consisting of a single marker, so it is possible 
to change the marker after the tick has been created:
ax = plt.subplot(1,1,1)
ticks = ax.xaxis.get_majorticklines()
mytick = ticks[3]
mytick.set_marker(2)
plt.draw()
This will flip the first tick on the top border (the one for 0.2).
left, right, up, down are 0, 1, 2, 3.
Eric
>
> Regards,
>
> -JJ
>
>
>
>
> On Tue, Nov 2, 2010 at 4:22 AM, Bartosz Telenczuk
> <b.t...@bi...> wrote:
>> Hi all,
>>
>> Is it possible to set direction (in or out) individually for each tick. I know about the rc setting ("(x/y)tick.direction") , but I need a finer control over the ticks.
>>
>> Thanks,
>>
>> Bartek
>>
>> ------------------------------------------------------------------------------
>> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
>> Create new apps& games for the Nokia N8 for consumers in U.S. and Canada
>> 10ドル million total in prizes - 4ドルM cash, 500 devices, nearly 6ドルM in marketing
>> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
>> http://p.sf.net/sfu/nokia-dev2dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
> ------------------------------------------------------------------------------
> Achieve Improved Network Security with IP and DNS Reputation.
> Defend against bad network traffic, including botnets, malware,
> phishing sites, and compromised hosts - saving your company time,
> money, and embarrassment. Learn More!
> http://p.sf.net/sfu/hpdev2dev-nov
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: David F. <dp...@sh...> - 2010年11月03日 05:18:30
I am trying to use matplotlib (for the first time) to graph the address space 
usage of an application against time. The data is written to a log file by 
trace statements throughout the source code of the application. The trace 
statements contain the current address space usage as well as a timer value 
with millisecond granularity.
My data in the y-axis (address space usage) is fairly uniform (0-2000 MB 
values), but my data in the x-axis (the time at which the the trace statements 
were executed) is highly clustered. For example, I have approximately 150 
data points over a 5 minute run, but some of the data points are only 10ms 
apart.
I would like to annotate each point on the graph with the line number in the 
log file so that the user can look up what was happening at that point. I have 
succeeded, but the graph isn't readable because there is so much overlap in 
the points.
Is there a standard way that people display data like this? I don't really 
like the idea of equally spacing all of the points along the x-axis because 
you lose the understanding of the timing. One idea I had was to have some 
sort of vertical break in the graph at areas where there was a long gap 
without a data point, but I have no idea whether it's possible to implement 
something like that in matplotlib.
The output format hasn't been strictly specified, so if you have any ideas of 
how I can produce a useful graph, I would be happy to hear them.
Thanks,
Dave
From: Nikolaus R. <Nik...@ra...> - 2010年11月03日 03:00:26
Hi,
Fantastic, path_effect is exactly what I'm looking for. Thanks!
-Niko
On 11/02/2010 10:16 PM, Jae-Joon Lee wrote:
> You may use annotate with which you can specify offsets.
> 
> http://matplotlib.sourceforge.net/api/pyplot_api.html?highlight=annotate#matplotlib.pyplot.annotate
> 
> Or, you may consider to use the path_effect (available w/ v1.0).
> 
> http://matplotlib.sourceforge.net/examples/pylab_examples/patheffect_demo.html
> 
> Regards,
> 
> -JJ
> 
> 
> On Wed, Nov 3, 2010 at 10:44 AM, Nikolaus Rath <Nik...@ra...> wrote:
>> Hello,
>>
>> I am placing a text object in a place where the background is sometimes
>> dark and sometimes light, so the text is hard to see. Adding a
>> background to the text object itself looks a bit ugly, so I am wondering
>> if there is a way to add a shadow to the text itself.
>>
>> What's the best way to do this?
>>
>> I thought about redrawing the same text just offset by a fraction of the
>> text size, but I can't quite figure out how to do the placement
>> properly. My rough idea is the get the position of the text in pixel
>> coordinates, add an offset to it and then position it with display
>> coordinates as well. But how do I get the display coordinates of
>> something that I placed in axes coordinates? And how to I determine how
>> many pixels I need to offset without knowing the dpi?
>>
>>
>> Best,
>>
>> -Nikolaus
>>
>> --
>> »Time flies like an arrow, fruit flies like a Banana.«
>>
>> PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
>>
>> ------------------------------------------------------------------------------
>> Achieve Improved Network Security with IP and DNS Reputation.
>> Defend against bad network traffic, including botnets, malware,
>> phishing sites, and compromised hosts - saving your company time,
>> money, and embarrassment. Learn More!
>> http://p.sf.net/sfu/hpdev2dev-nov
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
 -Nikolaus
-- 
 »Time flies like an arrow, fruit flies like a Banana.«
 PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
From: Joe K. <jki...@wi...> - 2010年11月03日 02:37:52
For whatever it's worth, after a lot of wrangling, I think I solved most of
my problems (though perhaps not in the most efficient way).
In case anyone else is looking for similar functionality, here's a callback
function that will autowrap text objects to the inside of the axis they're
plotted in, and should handle any font, rotation, etc that you throw at it.
(The previous version had a lot of bugs).
Hope someone finds it useful, at any rate...
-Joe
[image: E2G1j.png]
import matplotlib.pyplot as plt
def main():
 """Draw some very long strings on a figure and have the auto-wrapped
 to the axis boundaries. Try resizing the figure!!"""
 fig = plt.figure()
 plt.axis([0, 10, 0, 10])
 t = "This is a really long string that I'd rather have wrapped so"\
 " that it doesn't go outside of the figure, but if it's long"\
 " enough it will go off the top or bottom!"
 t2 = r"Furthermore, if I put mathtext in here, it won't mutilate it,"\
 " but will treat it like a really long word. For example: "\
 r"$\frac{\sigma}{\gamma} - e^{\theta \pm 5}$ won't be mangled!"
 plt.text(5, 10, t2, size=14, ha='center', va='top', family='monospace')
 plt.text(3, 0, t, family='serif', style='italic', ha='right')
 plt.text(4, 1, t, ha='left', family='Times New Roman', rotation=15)
 plt.text(5, 3.5, t, ha='right', rotation=-15)
 plt.title("This is a really long title that I want to have wrapped so"\
 r" it does not go outside the axis boundaries", ha='center')
 # All we do to autowrap everything is connect a callback function...
 fig.canvas.mpl_connect('draw_event', on_draw)
 plt.show()
def on_draw(event):
 """Auto-wraps all text objects in a figure at draw-time"""
 import matplotlib as mpl
 fig = event.canvas.figure
 # Cycle through all artists in all the axes in the figure
 for ax in fig.axes:
 for artist in ax.get_children():
 # If it's a text artist, wrap it...
 if isinstance(artist, mpl.text.Text):
 autowrap_text(artist, event.renderer)
 # Temporarily disconnect any callbacks to the draw event...
 # (To avoid recursion)
 func_handles = fig.canvas.callbacks.callbacks[event.name]
 fig.canvas.callbacks.callbacks[event.name] = {}
 # Re-draw the figure..
 fig.canvas.draw()
 # Reset the draw event callbacks
 fig.canvas.callbacks.callbacks[event.name] = func_handles
def autowrap_text(textobj, renderer):
 """Wraps the given matplotlib text object so that it doesn't exceed the
 boundaries of the axis it is plotted in."""
 # Get the starting position of the text in pixels...
 x0, y0 = textobj.get_transform().transform(textobj.get_position())
 # Get the extents of the current axis in pixels...
 clip = textobj.get_axes().get_window_extent()
 # Set the text to rotate about the left edge (nonsensical otherwise)
 textobj.set_rotation_mode('anchor')
 # Get the amount of space in the direction of rotation to the left and
 # right of x0, y0 (left and right are relative to the rotation)
 rotation = textobj.get_rotation()
 right_space = min_dist_inside((x0, y0), rotation, clip)
 left_space = min_dist_inside((x0, y0), rotation - 180, clip)
 # Use either the left or right distance depending on the h-alignment.
 alignment = textobj.get_horizontalalignment()
 if alignment is 'left':
 new_width = right_space
 elif alignment is 'right':
 new_width = left_space
 else:
 new_width = 2 * min(left_space, right_space)
 # Convert to characters with a minimum width of 1 character
 wrap_width = max(1, new_width // pixels_per_char(textobj))
 try:
 wrapped_text = safewrap(textobj.get_text(), wrap_width)
 except TypeError:
 # This appears to be a single word
 wrapped_text = textobj.get_text()
 textobj.set_text(wrapped_text)
def min_dist_inside(point, rotation, box):
 """Gets the space in a given direction from "point" to the boundaries
 of "box" (where box is an object with x0, y0, x1, & y1 attributes,
 point is a tuple of x,y, and rotation is the angle in degrees)"""
 from math import sin, cos, radians
 x0, y0 = point
 rotation = radians(rotation)
 distances = []
 threshold = 0.0001
 if cos(rotation) > threshold:
 # Intersects the right axis
 distances.append((box.x1 - x0) / cos(rotation))
 if cos(rotation) < -threshold:
 # Intersects the left axis
 distances.append((box.x0 - x0) / cos(rotation))
 if sin(rotation) > threshold:
 # Intersects the top axis
 distances.append((box.y1 - y0) / sin(rotation))
 if sin(rotation) < -threshold:
 # Intersects the bottom axis
 distances.append((box.y0 - y0) / sin(rotation))
 return min(distances)
def pixels_per_char(textobj):
 """Determines the average width of a character of the given textobj
 by drawing a test string and calculating it's length"""
 test_text = 'Try something like a test'
 orig_text = textobj.get_text()
 textobj.set_text(test_text)
 width = textobj.get_window_extent().width
 textobj.set_text(orig_text)
 return width / len(test_text)
def safewrap(text, width):
 """Wraps text, but avoids putting linebreaks in tex strings"""
 import textwrap
 # If it's not a tex string, just wrap it as usual...
 if '$' not in text:
 return textwrap.fill(text, width)
 # Tex segments will be inside two "$"'s, so we want the odd items
 segments = text.split('$')
 tex = segments[1::2]
 # Temporarily replace spaces and dashes inside tex segments so that
 # they will be treated as long words by textwrap...
 segments[1::2] = [x.replace(' ','').replace('-','') for x in tex]
 # Rejoin the temp tex strings with the rest of the text and wrap it
 temp_text = '$'.join(segments)
 wrapped = textwrap.fill(temp_text, width, break_long_words=False)
 # Put the original tex strings back in between $'s
 segments = wrapped.split('$')
 segments[1::2] = tex
 return '$'.join(segments)
if __name__ == '__main__':
 main()
From: Jae-Joon L. <lee...@gm...> - 2010年11月03日 02:16:27
You may use annotate with which you can specify offsets.
http://matplotlib.sourceforge.net/api/pyplot_api.html?highlight=annotate#matplotlib.pyplot.annotate
Or, you may consider to use the path_effect (available w/ v1.0).
http://matplotlib.sourceforge.net/examples/pylab_examples/patheffect_demo.html
Regards,
-JJ
On Wed, Nov 3, 2010 at 10:44 AM, Nikolaus Rath <Nik...@ra...> wrote:
> Hello,
>
> I am placing a text object in a place where the background is sometimes
> dark and sometimes light, so the text is hard to see. Adding a
> background to the text object itself looks a bit ugly, so I am wondering
> if there is a way to add a shadow to the text itself.
>
> What's the best way to do this?
>
> I thought about redrawing the same text just offset by a fraction of the
> text size, but I can't quite figure out how to do the placement
> properly. My rough idea is the get the position of the text in pixel
> coordinates, add an offset to it and then position it with display
> coordinates as well. But how do I get the display coordinates of
> something that I placed in axes coordinates? And how to I determine how
> many pixels I need to offset without knowing the dpi?
>
>
> Best,
>
>  -Nikolaus
>
> --
> »Time flies like an arrow, fruit flies like a Banana.«
>
> PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
>
> ------------------------------------------------------------------------------
> Achieve Improved Network Security with IP and DNS Reputation.
> Defend against bad network traffic, including botnets, malware,
> phishing sites, and compromised hosts - saving your company time,
> money, and embarrassment.  Learn More!
> http://p.sf.net/sfu/hpdev2dev-nov
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Nikolaus R. <Nik...@ra...> - 2010年11月03日 01:45:15
Hello,
I am placing a text object in a place where the background is sometimes
dark and sometimes light, so the text is hard to see. Adding a
background to the text object itself looks a bit ugly, so I am wondering
if there is a way to add a shadow to the text itself.
What's the best way to do this?
I thought about redrawing the same text just offset by a fraction of the
text size, but I can't quite figure out how to do the placement
properly. My rough idea is the get the position of the text in pixel
coordinates, add an offset to it and then position it with display
coordinates as well. But how do I get the display coordinates of
something that I placed in axes coordinates? And how to I determine how
many pixels I need to offset without knowing the dpi?
Best,
 -Nikolaus
-- 
 »Time flies like an arrow, fruit flies like a Banana.«
 PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
From: Nikolaus R. <Nik...@ra...> - 2010年11月03日 01:38:48
Attachments: test.png
"Stan West" <sta...@pu...> writes:
>> From: Nikolaus Rath [mailto:Nik...@pu...] 
>> Sent: Saturday, October 30, 2010 16:17
>> 
>> but if I try to do the same think with the Y axis, everything looks
>> messed up (e.g. the matrix is no longer square):
>
> The matrix remains square for me using a build from Subversion. What's your
> matplotlib.__version__?
In [16]: matplotlib.__version__
Out[16]: '1.0.0'
I attached the result of fig.savefig(). Let's see if it makes it through
the list.
Best,
 -Nikolaus
-- 
 »Time flies like an arrow, fruit flies like a Banana.«
 PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
From: Jae-Joon L. <lee...@gm...> - 2010年11月03日 01:18:37
A quick (and not safe) way w/ mpl v1.0 is,
 ax = plt.subplot(111)
 ax.plot(np.arange(3))
 ax.set_xticks([0, 0.5, 1., 1.5, 2.])
 mytick = ax.xaxis.majorTicks[2]
 mytick._apply_params(tickdir="out")
I don't think there is a way to do this only using public apis.
I myself actually prefer to create a separate axis (or axes), but this
will be more trickier than above solution.
Regards,
-JJ
On Tue, Nov 2, 2010 at 4:22 AM, Bartosz Telenczuk
<b.t...@bi...> wrote:
> Hi all,
>
> Is it possible to set direction (in or out) individually for each tick. I know about the rc setting ("(x/y)tick.direction") , but I need a finer control over the ticks.
>
> Thanks,
>
> Bartek
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
> 10ドル million total in prizes - 4ドルM cash, 500 devices, nearly 6ドルM in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

Showing 17 results of 17

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