matplotlib / matplotlib Goto Github PK
View Code? Open in Web Editor NEWmatplotlib: plotting with Python
Home Page: https://matplotlib.org/stable/
matplotlib: plotting with Python
Home Page: https://matplotlib.org/stable/
Reportedly this test doesn't pass in all circumstances.
The sphinx plot_directive is failing on geo_demo and artist_tests, with both master and v1.0.x. Tested with sphinx-1.0.7:
/home/darren/.local/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.py:322: PlotWarning: Exception running plot /home/darren/Projects/matplotlib/doc/mpl_examples/pylab_examples/geo_demo.py
Traceback (most recent call last):
File "/home/darren/.local/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.py", line 319, in render_figures
run_code(plot_path, function_name, plot_code, context=context)
File "/home/darren/.local/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.py", line 230, in run_code
"__plot__", fd, fname, ('py', 'r', imp.PY_SOURCE))
File "geo_demo.py", line 10, in <module>
File "/home/darren/.local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 658, in subplot
a = fig.add_subplot(*args, **kwargs)
File "/home/darren/.local/lib/python2.7/site-packages/matplotlib/figure.py", line 766, in add_subplot
a = subplot_class_factory(projection_class)(self, *args, **kwargs)
File "/home/darren/.local/lib/python2.7/site-packages/matplotlib/axes.py", line 8397, in __init__
self._axes_class.__init__(self, fig, self.figbox, **kwargs)
File "custom_projection_example.py", line 33, in __init__
TypeError: expected string or Unicode object, NoneType found
and:
/home/darren/.local/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.py:322: PlotWarning: Exception running plot /home/darren/Projects/matplotlib/doc/mpl_examples/units/artist_tests.py
Traceback (most recent call last):
File "/home/darren/.local/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.py", line 319, in render_figures
run_code(plot_path, function_name, plot_code, context=context)
File "/home/darren/.local/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.py", line 230, in run_code
"__plot__", fd, fname, ('py', 'r', imp.PY_SOURCE))
File "artist_tests.py", line 30, in <module>
File "/home/darren/.local/lib/python2.7/site-packages/matplotlib/collections.py", line 852, in __init__
self.set_segments(segments)
File "/home/darren/.local/lib/python2.7/site-packages/matplotlib/collections.py", line 861, in set_segments
seg = np.asarray(seg, np.float_)
File "/home/darren/.local/lib/python2.7/site-packages/numpy/core/numeric.py", line 284, in asarray
return array(a, dtype, copy=False, order=order)
ValueError: setting an array element with a sequence.
Original report at SourceForge, opened Sun Mar 14 04:26:54 2010
Python 2.6.4, Matplotlib 0.99.1, PyQT4 4.5.4, Windows XT SP3
When Multicusor is on and zoom too (toolbar icon), cursor line is not displayed when mouse cursor is in the figure. If zoom is off, it's ok. This doesn't appears with Cursor (line present with or without zoom on).
Multicursor is respecting the widgetlock, and Cursor is not; it is not clear why. Maybe both should respect the lock, but only the zoom-to-rect should set the lock. It is not entirely clear to me why a lock is needed even then.
I am using the MacOS X backend, and when plotting and saving a file, the dpi= option seems to be ignored:
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
fig.savefig('test.tif', dpi=1000)
produces a file that has dpi=72. Is this normal, or is it a bug? If it is normal that dpi doesn't have any effect, it might be worth adding a warning so the user knowns the dpi option will be ignored.
This is a n issue we hit during the CTPUG matplotlib-py3 sprint, but also applies to matplotlib trunk.
The current check for whether an extension is present in the file breaks if the name includes a directory containing '.'.
Original report at SourceForge, opened Thu Dec 31 13:32:15 2009
For bar3d(), overlapping for the bars can be wrong from certain views. Attached is an example of the problem using hist3d_demo.py
Original report at SourceForge, opened Tue Aug 17 15:10:47 2010
if a draggable legend is moved with no offset (just click and release) an error occurs at "class DraggableOffsetBox(DraggableBase)" in routine get_loc_in_canvas at line: ox, oy = offsetbox._offset.
In this case offsetbox._offset contains a function, not a tuple of 2 points.
The patch is attached.
Unfortunately, it will take me a few days to submit it (I currently don''t have a local svn copy set up).
-JJ
JJ, I think this is in your area of expertise. It is illustrated by examples/animation/draggable_legend.py. Click and release on the text legend.
Original report at SourceForge, opened Thu Jul 1 14:35:06 2010
There appears to be an issue with some matplotlib widgets that are packaged in py2exe where navigation button icons are not displayed. To remedy this problem, I changed icon file names in backend_qt4.py from .svg to .png. One clue to this problem was that one icon was showing, which was the subplots icon. In the function NavigationToolbar2QT._init_toolbar, it is the only icon using a png image.
Reported by Pål Gunnar Ellingsen at http://thread.gmane.org/gmane.comp.python.matplotlib.general/26638
A similar-looking problem: http://thread.gmane.org/gmane.os.macosx.fink.user/32231
Somehow dviread.PsfontsMap doesn't find cmr12 in pdftex.map, even though that's one of the really core TeX fonts that every reasonable TeX installation will have.
Branch jkseppan/dviread-bug has some extra debugging output calls at level debug-annoying.
This is an issue originally reported in the mailing list by Brannon ([email protected]).
http://old.nabble.com/eps-and-useTex%3A-tick-labels-drawn-over-legend-box-td31744864.html
Hi,
I am having trouble with matplotlib 1.0.1 drawing the axis tick labels over
the legend box in the eps output when useTex is set to true. The plot shown
after calling plt.show() looks fine, as does the output in pdf, png, svg
etc. Only the postscript appears to be affected.
The following simple example produces the png and eps files given at the
bottom of this post:
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import rc
rc('text', usetex=True)
g1, = plt.plot([1,2,3,4],[500,600,700,800])
g2, = plt.plot([1,2,3,4],[700,300,700,200])
g3, = plt.plot([1,2,3,4],[800,600,900,800])
plt.figlegend([g1,g2,g3],['test1','test2','test3'],'upper left')
plt.savefig('image.png')
plt.savefig('image.eps')
plt.show()
http://old.nabble.com/file/p31744864/image.eps image.eps
http://old.nabble.com/file/p31744864/image.png image.png
I would very much appreciate some help resolving this issue.
Thanks
Original report at SourceForge, opened Wed Sep 1 13:52:54 2010
When using log scale, if the error is larger than flux, the error bar does not plot at all:
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.errorbar([1.],[1.],yerr=[2.])
ax.set_yscale('log')
fig.savefig('test.png')
However, I think it would make more correct to plot the line for the errorbar, and to make it go down to -infinity.
thread at http://www.mail-archive.com/[email protected]/msg20088.html or http://sourceforge.net/mailarchive/forum.php?thread_name=4D4EA423.5090802%40vanderHoeven.biz&forum_name=matplotlib-users
basically, use png files for all icon files in backend_qt4.py instead of svg to circumvent dependency
The version of pytz included in matplotlib is somewhat outdated (version 2010o). The latest version of pytz (version 2011c) includes updates to the timezone database and fixes that make pytz compatible with Python 3.1 and 3.2.
Original report at SourceForge, opened Wed Jun 16 02:16:45 2010
I'm trying to use the matplotlib Sphinx plot extension to add some diagrams to Sphinx documentation. However, I've come across an issue: My Sphinx documentation uses the "separate directories for source and build" option. It seems that the matplotlib plot extension doesn't work well with this option, because:
I think the "pyplot" directory should be under the "source" directory. But I had to put it one level up from the "source" directory otherwise it wouldn't be found.
When I try to build, I get error messages such as:
/home/craig-nat/MySoftware/cobs-python/doc/source/index.rst:: WARNING: image file not readable: build/pyplots/cobsr_overhead.png
It should be "../build/pyplots/cobsr_overhead.png" instead I think.
This seems to be working in Matplotlib-1.0.0.
My Ubuntu box doesn't have 1.0.0 as a deb, so I downloaded the source an copied matplotlib-1.0.0/lib/matplotlib/sphinxext to my sphinx project.
I then updated my conf.py to use the copy:
extensions =
[
'sphinxext.mathmpl',
'sphinxext.only_directives',
'sphinxext.plot_directive',
'sphinx.ext.autodoc',
'sphinx.ext.doctest'
]
And inlined plot directive work.
I also got this bug with Sphinx 1.0b2, matplotlib 0.99.1.1
I was able to resolve it with two changes to matplotlib/sphinxext/plot_directive.py
Line 276:
from:
tmpdir = os.path.join('build', outdir)
to:
tmpdir = outdir
Line 320:
from:
for format in formats[1:]:
to:
for format in formats:
Yes, Sphinx 1.0b2.
Which version of Sphinx? I believe you may get this message with Sphinx1.0b2.
Original report at SourceForge, opened Thu Nov 19 15:42:05 2009
Following code does not represents the asked color variation for the plots in 3D.
Same problem appends if a variable size is asked for exemple (via s=z argument).
from mpl_toolkits.mplot3d.axes3d import *
import pylab as plt
x=y=z=range(10)
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter3D(x,y,z,c=z,cmap=plt.cm.jet)
plt.show()
Original report at SourceForge, opened Tue Jun 22 07:58:14 2010
The autoscale seems to be broken in trunk in this example:
from pylab import *
hist(rand(100),bins=20,histtype="step",log=1)
Sorry for not being explicit enough. The lower y-limit was previously set to a value closer to the lowest non-zero bin, and not 1E-100.
That being said, the behaviour in rev 8623 is actually sane again.
Can you be more specific about what you would have expected to see?
Uploaded the plot that I get here, from rev 8475.
In what way is it broken? The axes appears to contain all of the data. Some of the lines are right under the axes line at the top, but that is expected behavior. If you want some "padding", that would have to be added manually.
I got this error while using matplotlib 1.0.1 on OS X 10.6.6.
Traceback (most recent call last):
File "python2.7/site-packages/matplotlib/backend_bases.py", line 1625, in motion_notify_event
self.callbacks.process(s, event)
File "python2.7/site-packages/matplotlib/cbook.py", line 265, in process
proxy(_args, *_kwargs)
File "python2.7/site-packages/matplotlib/cbook.py", line 191, in call
return mtd(_args, *_kwargs)
File "python2.7/site-packages/matplotlib/backend_bases.py", line 2573, in drag_zoom
self.draw_rubberband(event, x, y, lastx, lasty)
File "python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 420, in draw_rubberband
self.canvas.set_rubberband(x0, y0, x1, y1)
TypeError: integer argument expected, got float
urllib2's HTTPSHandler requires python to have been compiled with support for SSL. For those python installs that were not, cbook is unimportable.
matplitlib.dates.drange can return unexpected dates, depending on the delta. I think it's a precision issue from using fractions of a day as the delta in drange. For example, changing hours=6 to hours=4 in the main section of dates.py
d1 = datetime.datetime( 2000, 3, 1, tzinfo=tz)
d2 = datetime.datetime( 2000, 3, 5, tzinfo=tz)
delta = datetime.timedelta(hours=6) # change to 4 to see the issue
dates = drange(d1, d2, delta)
gives dates such as 2000-03-01 23:59:59.999989+00:00 instead of 2000-03-02 00:00:00+00:00
Would it be better to use datetimes and timedeltas to fill in the array returned by drange and convert the array to fractions of a day at the end of the calculations? Something like
def drange(dstart, dend, delta):
"""
Return a date range as float Gregorian ordinals. dstart and
dend are :class:datetime
instances. delta is a
:class:datetime.timedelta
instance.
"""
dates = [dstart]
f1 = dstart + delta
while f1 <= dend:
dates.append(f1)
f1 += delta
return date2num(dates)
I ran into this problem trying to use drange to create 4 hour ticks in a date plot on a mac running OS X 10.6 with python 2.7.1, matplotlib 1.1.0 and numpy 2.0.0.dev-3071eab.
Thanks
Just wanted to make a quick note of this - it would be a good bug for someone who wants to dive into matplotlib in a very defined manner.
Additionally, it'd be nice to have all of the markerstyle in plot supported by scatter, and vice versa - in case that isn't the case already for everything other than *
In [956]: plt.scatter(0,0,marker='*')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/home/pi/tmp/local/lib/python2.5/site-packages/matplotlib/pyplot.pyc in scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, faceted, verts, hold, **kwargs)
2374 if hold is not None:
2375 ax.hold(hold)
-> 2376 try:
2377 ret = ax.quiver(*args, **kw)
2378 draw_if_interactive()
/home/pi/tmp/local/lib/python2.5/site-packages/matplotlib/axes.pyc in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, faceted, verts, **kwargs)
5742
5743 self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
-> 5744 x = self.convert_xunits(x)
5745 y = self.convert_yunits(y)
5746
ValueError: Unknown marker symbol to scatter
In [957]: plt.clf()
In [958]: plt.plot(0,0,'*')
Out[958]: [<matplotlib.lines.Line2D object at 0x7f3467c18d10>]
Original report at SourceForge, opened Wed Oct 7 13:51:02 2009
The documentation on mpl_toolkits.mplot3d.axes3d.Axes3D.scatter states:
Keyword arguments are passed on to
:func:~matplotlib.axes.Axes.scatter
.
This does not seem to be the case (see attached code)
Note: I run Linux RedHat 5, python v2.6.2, with matplotlib v0.99.1.1 installed with backend = TkAgg
I am attempting to use the hatching feature in matplotlib, which works fine when displaying to screen. However when I save the figure to pdf format, the hatch marks are not rendered:
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,2*np.pi,100)
plt.figure()
plt.fill(x,np.sin(x),color='blue',alpha=0.5,hatch='/')
plt.show()
plt.savefig('./test.pdf',format='pdf')
I am using matplotlib 1.0.1 on OS X 10.6.6 (Specifically the Enthought Python Distribution v7).
Upon posting the issue initially to Stackoverflow, I received a workaround for the issue by using:
plt.fill(x,np.sin(x),color='blue',alpha=0.5)
plt.fill(x,np.sin(x),color='None',alpha=0.5,edgecolor='blue',hatch='/')
Not sure why this works, but it saves the pdf correctly when using the two commands in combination.
Original report at SourceForge, opened Fri Jul 9 19:57:36 2010
On a recent ubuntu linux with the gtkagg backend, there appears to be a one pixel error in animation blitting. Eg, see dynamic_image.py at
http://github.com/dopplershift/Animation/tree/master/examples/
I doubt this has to do with Ryan's package as he just uses blit, so it is probably a bug in mpl (using 1.0.0svn)
JDH
The following code should produce an image that is 3600x3216 and completely blue, but there is a 1-pixel white border on the bottom and left:
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as mpl
fig = mpl.figure(figsize=(12.00, 12.00 * 3216. / 3600.))
ax = fig.add_axes([0.,0.,1.,1.])
ax.set_autoscale_on(False)
ax.xaxis.set_view_interval(0.5, 3600.5)
ax.yaxis.set_view_interval(0.5, 3216.5)
for tick in ax.xaxis.get_ticklines():
tick.set_visible(False)
for tick in ax.yaxis.get_ticklines():
tick.set_visible(False)
for label in ax.xaxis.get_ticklabels():
label.set_visible(False)
for label in ax.yaxis.get_ticklabels():
label.set_visible(False)
for key in ax.spines:
ax.spines[key].set_visible(False)
ax.imshow(np.zeros((3216, 3600)), extent=(0.5, 3600.5, 0.5, 3216.5), origin='lower')
fig.savefig('test.png', dpi=300, transparent=False)
If autoscale is turned on, it looks fine, but I need to keep autoscale off for other reasons, so I want to understand what's going on here. If I do:
print ax.xaxis.get_view_interval()
print ax.yaxis.get_view_interval()
I get:
[ 0. 3600.5]
[ 0. 3216.5]
which must be part of the issue here, since the minima should be 0.5, not 0. If I use set_xlim and set_ylim instead of ax.xaxis.set_view_interval, it works fine, so there must be a bug in set_view_interval?
Note that this issue is not related to #117, and occurs even if the patch in #117 is applied.
The following code works:
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.contourf([[0.,1.], [1.,0.]], levels=[0.5, 1.0, 2.0])
fig.savefig('contourf.png')
but if I try and specify a single level, the code crashes:
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.contourf([[0.,1.], [1.,0.]], levels=[0.5])
fig.savefig('contourf.png')
The exception is:
Traceback (most recent call last):
File "test.py", line 7, in <module>
ax.contourf([[0.,1.], [1.,0.]], levels=[0.5])
File "/Users/tom/Library/Python/2.6/site-packages/matplotlib/axes.py", line 7403, in contourf
return mcontour.QuadContourSet(self, *args, **kwargs)
File "/Users/tom/Library/Python/2.6/site-packages/matplotlib/contour.py", line 1103, in __init__
ContourSet.__init__(self, ax, *args, **kwargs)
File "/Users/tom/Library/Python/2.6/site-packages/matplotlib/contour.py", line 719, in __init__
self.allsegs, self.allkinds = self._get_allsegs_and_allkinds()
File "/Users/tom/Library/Python/2.6/site-packages/matplotlib/contour.py", line 1136, in _get_allsegs_and_allkinds
lowers, uppers = self._get_lowers_and_uppers()
File "/Users/tom/Library/Python/2.6/site-packages/matplotlib/contour.py", line 820, in _get_lowers_and_uppers
if self.zmin == lowers[0]:
IndexError: index out of bounds
Original report at SourceForge, opened Tue Aug 17 02:13:52 2010
This is my first bug submission; Please ask if more information is needed.
I'm attempting to plot two data sets on a single figure with a common x axis but separate y axes. I want the first set to correspond to the right y-axis. My strategy is to add a set of axes to the figure, then create a second set of axes using twinx(), then use plot_date() to add data to the second set of axes. It appears that there is some problem in the order in which things are done that causes this to fail when the figure is drawn.
I think the problem may have something to do with the default axis limits being (0.0, 1.0). These limits cannot be converted to dates since the range for dates is >= 1.0.
Here is a simplified example of code that will fail:
import matplotlib.pyplot as plt
import matplotlib.dates
import datetime
t = datetime.datetime.now().date()
left_varr = range(10)
right_varr = range(10)
right_varr.reverse()
tarr = matplotlib.dates.date2num([t + datetime.timedelta(days=i) for i in varr])
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax2 = ax1.twinx()
ax2.plot_date(tarr, varr)
fig.canvas.draw()
This has been a known problem but not fixed yet. There could be a few other workarounds. One is not to use autoscale_view.
ax1 = fig.add_subplot(1,1,1)
ax2 = ax1.twinx()
ax1.set_autoscalex_on(False)
ax2.set_autoscalex_on(False)
ax2.plot_date(tarr, left_varr)
ax2.set_xlim(min(tarr), max(tarr))
or add same data to the other axes but makes it invisible.
ax2.plot_date(tarr, left_varr)
l1, = ax1.plot_date(tarr, left_varr)
l1.set_visible(False)
I think one way to solve this issue is to check if axes have any artist (has_data method), and include only those axes with child artists during the autoscale_view. However, I'll let others review it.
Oops, I hit the add button too soon.
Continuing on:
The resulting traceback is:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, _args, *_kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py", line 798, in draw
func(_args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, *_kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axes.py", line 1942, in draw
a.draw(renderer)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, _args, *_kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axis.py", line 971, in draw
tick_tups = [ t for t in self.iter_ticks()]
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axis.py", line 904, in iter_ticks
majorLocs = self.major.locator()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/dates.py", line 743, in call
self.refresh()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/dates.py", line 752, in refresh
dmin, dmax = self.viewlim_to_dt()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/dates.py", line 524, in viewlim_to_dt
return num2date(vmin, self.tz), num2date(vmax, self.tz)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/dates.py", line 289, in num2date
if not cbook.iterable(x): return _from_ordinalf(x, tz)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/dates.py", line 203, in _from_ordinalf
dt = datetime.datetime.fromordinal(ix)
ValueError: ordinal must be >= 1
I've come up with a work around that somewhat mimics twinx() and allows the rest of my code to work properly.
ax1 = fig.add_subplot(1,1,1)
ax1.plot_date(tarr, right_varr)
ax1.yaxis.tick_right()
ax1.yaxis.set_label_position('right')
fig.canvas.draw()
ax2 = ax1.figure.add_axes(ax1.get_position(True), sharex=ax1, frameon=False)
ax2.yaxis.tick_left()
ax2.xaxis.set_visible(False)
ax2.plot_date(tarr, left_varr)
fig.canvas.draw()
This workaround sets up my axes as desired and allows the rest of my code to function as intended.
arrow(3000, 5e-15, 0, .5e-15)
ylim(0,1e-14)
xlim(2000, 4000)
should print a line from 3000, 5e-15 to 3000 5.5e-15, but it plots a line that goes much higher that 1e-14.
Cheers
Wolfgang
When I run the test suite, I get some errors such as:
======================================================================
ERROR: matplotlib.tests.test_mathtext.test_mathtext_font_stix
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/darren/.local/lib/python2.7/site-packages/nose-1.0.0-py2.7.egg/nose/case.py", line 187, in runTest
self.test(*self.arg)
File "/home/darren/.local/lib/python2.7/site-packages/matplotlib/testing/decorators.py", line 32, in failer
result = f(*args, **kwargs)
File "/home/darren/.local/lib/python2.7/site-packages/matplotlib/testing/decorators.py", line 126, in decorated_compare_images
'(RMS %(rms).3f)'%err)
ImageComparisonFailure: images not close: /home/darren/result_images/test_mathtext/mathtext_font_stix.png vs. /home/darren/result_images/test_mathtext/expected-mathtext_font_stix.png (RMS 122152.917)
These should yield failures rather than errors in the test report.
Original report at SourceForge, opened Tue Jun 15 22:10:00 2010
The alpha parameter in mpl_tookits.mplot3d.Axes3D doesn't have effect. It's always displayed as alpha=1.
Sorry for replying late.
I mean, there's no 3D effect in 3D scatter. (The value of alpha doesn't affect the displaying in 3D scatter.)
Here's my code:
def visualize_fdist(self):
xx, yy, zz = (self.fdist > 0).nonzero()
if len(xx) == 0:
print "nothing to display"
return
vals = sp.array(self.fdist[xx, yy, zz], sp.int16)
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter3D(yy, zz, zs=xx, marker='s', c=vals, alpha=0.50, s=sp.power(2, vals + 2), cmap=plt.cm.jet)
ax.set_xlabel('width')
ax.set_ylabel('time')
ax.set_zlabel('height')
ax.set_xlim3d((0, self.vwidth))
ax.set_ylim3d((0, self.vdepth))
ax.set_zlim3d((0, self.vheight))
ax.invert_yaxis()
ax.grid(True)
plt.show()
Thank you
Collections have a set_alpha method that accepts None.
Antiw: I don't understand what the problem is. Please provide a tiny script to illustrate it. What is it that you want to do but can't?
Note that alpha for each scatter point is being manipulated to indicate the 3rd dimension. It would be easy enough to have the collection alpha value applied as a multiplier. I suspect this would not have any ill effects, although it would be inconsistent with the way alpha is handled in 2-D.
matplotlib 1.0svn
In: /usr/local/lib/python2.6/dist-packages/mpl_toolkits/mplot3d/art3d.py
Line 303, 304:
303 #FIXME: mpl allows us no way to unset the collection alpha value
304 self._alpha = None
Correct: The scatter is always displayed as alpha is None (in version 1.0, they set the default value of alpha None)
The following example demonstrates that if imshow
uses interpolation='nearest'
, the dpi=
argument in savefig
has no effect:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.imshow(np.random.random((1000, 1000)))
plt.savefig('test1.eps', dpi=1)
plt.savefig('test2.eps', dpi=10)
plt.savefig('test3.eps', dpi=100)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.imshow(np.random.random((1000, 1000)), interpolation='nearest')
plt.savefig('test4.eps', dpi=1)
plt.savefig('test5.eps', dpi=10)
plt.savefig('test6.eps', dpi=100)
because looking at the file sizes gives:
$ du -sh test?.eps
12K test1.eps
16K test2.eps
620K test3.eps
5.8M test4.eps
5.8M test5.eps
5.8M test6.eps
The following script:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(2,2,1)
ax.scatter([0.5], [0.5])
fig.savefig('test.jpg', bbox_inches='tight')
raises the following exception:
Traceback (most recent call last):
File "tif.py", line 8, in <module>
fig.savefig('test.jpg', bbox_inches='tight')
File "/Users/tom/Library/Python/2.6/site-packages/matplotlib/figure.py", line 1162, in savefig
self.canvas.print_figure(*args, **kwargs)
File "/Users/tom/Library/Python/2.6/site-packages/matplotlib/backend_bases.py", line 1943, in print_figure
**kwargs)
File "/Users/tom/Library/Python/2.6/site-packages/matplotlib/backend_bases.py", line 1803, in print_jpg
return image.save(filename_or_obj, **options)
File "/Users/tom/Library/Python/2.6/site-packages/PIL/Image.py", line 1423, in save
raise KeyError(ext) # unknown extension
KeyError: ''
and same for TIFF files. If bbox_inches='tight'
isn't supported, maybe a warning would be better?
I'm using 5df5830
Saving plots to pdf, using latex for font rendering (i.e. setting rcParams['text.usetex']=True) results in very large file size (~150kb for simple line plot with some mathematical latex expressions). This is due to all fonts being fully embedded into pdf.
When resulting pdf is postprocessed, so that only subset of fonts is embedded, file size is reduced drastically (e.g. from 150kb to 15kb).
The embedded fonts are of FontType=1.
Pdf backend should support embedding of subset of fonts when rcParams["text.usetex"]=True is used.
The following code no longer sets the bounding box correctly:
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
mpl.rc('text', usetex=True)
fig = plt.figure()
ax = fig.add_axes([0.1,0.1,0.3,0.3])
fig.savefig('test.eps', bbox_inches='tight')
This stopped working since commit 32f64b0, specifically the changes by @efiring.
Original report at SourceForge, opened Thu Dec 3 05:41:49 2009
Hi,
in the current version (0.99.0), color ("c") and size ("s") attributes to axes3d scatter plots do not work. Color seems to work for scalar colors, but size does not.
As a test case, take something like http://matplotlib.sourceforge.net/examples/mplot3d/scatter3d_demo.html (for which (scalar) color works) and add size:
ax.scatter(xs, ys, zs, c=c, s=c)
The problem seems to be present still in version 1.0.1 but 1.1.0svn seems to work correctly.
I am very interested in the fate of this bug. I have found a reply for this bug on Google: http://old.nabble.com/3D-Axes-scatter-:-no-possibility-to-vary-color-size-of-markers-td26335289.html
but there is little info on the bug page on Sourceforge.
This bug was filled against version 0.99.0 - I have version 0.99.1.2 on Centos 5.5 and I am still struggling with this bug.
As the reply on the mailing list said, this bug had been fixed in svn.
Could someone tell me when the fix will be available on Centos, or in which version of matplotlib it is actually fixed?
Or is there some workaround I could use to plot a colored scatter plot in 3D?
Thanks.
Original report at SourceForge, opened Thu Feb 25 16:02:13 2010
The 2D scatter plot ignores points that have NaN values. The 3D scatter plot should do the same to match the 2D functionality as closely as possible. Here is some test code to demonstrate:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
xs = np.array([1, np.nan, 3])
ys = np.array([10, 20, 30])
zs = np.array([1, 2, 3])
cs = [(1,0,0,1), (0,1,0,1), (0,0,1,1)]
fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(xs, ys, c=cs)
print '2D scatter OK'
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(xs, ys, zs, c=cs)
plt.show()
This is the exception that I get. The issue is that the zs, array has 3 values, when the xs and ys arrays only have 2. Because the NaN valued points are removed from the xs and ys arrays, but the zs array is untouched.
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 1410, in call
return self.func(_args)
File "/usr/local/lib/python2.6/site-packages/matplotlib/backends/backend_tkagg.py", line 212, in resize
self.show()
File "/usr/local/lib/python2.6/site-packages/matplotlib/backends/backend_tkagg.py", line 215, in draw
FigureCanvasAgg.draw(self)
File "/usr/local/lib/python2.6/site-packages/matplotlib/backends/backend_agg.py", line 394, in draw
self.figure.draw(self.renderer)
File "/usr/local/lib/python2.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *kl)
File "/usr/local/lib/python2.6/site-packages/matplotlib/figure.py", line 802, in draw
func(_args)
File "/usr/local/lib/python2.6/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 152, in draw
for col in self.collections]
File "/usr/local/lib/python2.6/site-packages/mpl_toolkits/mplot3d/art3d.py", line 303, in do_3d_projection
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs, renderer.M)
File "/usr/local/lib/python2.6/site-packages/mpl_toolkits/mplot3d/proj3d.py", line 202, in proj_transform_clip
vec = vec_pad_ones(xs, ys, zs)
File "/usr/local/lib/python2.6/site-packages/mpl_toolkits/mplot3d/proj3d.py", line 184, in vec_pad_ones
vec = np.array([xs,ys,zs,np.ones((len(xs)))])
ValueError: setting an array element with a sequence.
due to the cpython hg transition the version attribute of tkinter has been removed in python 3 and in the python 2.7 rc1 it does not contain a number anymore.
see http://bugs.python.org/issue12236
http://hg.python.org/cpython/file/f3553d5083f8/Lib/tkinter/__init__.py
This breaks the matplotlib build which parses version and expects a number:
OPTIONAL BACKEND DEPENDENCIES
libpng: 1.2.44
Traceback (most recent call last):
File "./setup.py", line 162, in <module>
if check_for_tk() or (options['build_tkagg'] is True):
File "/build/buildd/matplotlib-1.0.1/setupext.py", line 832, in check_for_tk
(Tkinter.__version__.split()[-2], Tkinter.TkVersion, Tkinter.TclVersion))
IndexError: list index out of range
Original report at SourceForge, opened Mon Oct 4 17:04:36 2010
draw_artist on mac os x gives me an error with the following script:
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
plt.figure()
subplot = plt.subplot(1,1,1)
axis = plt.imshow(np.random.random((10,10)))
plt.draw()
subplot.draw_artist(axis)
plt.show()
The traceback is:
Traceback (most recent call last):
File "matplotlib-bug.py", line 8, in
subplot.draw_artist(axis)
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/axes.py", line 1946, in draw_artist
a.draw(self._cachedRenderer)
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, _args, *_kwargs)
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/image.py", line 338, in draw
gc = renderer.new_gc()
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 105, in new_gc
self.gc.save()
RuntimeError: CGContextRef is NULL
matplotlib version: 1.0.0 (compiled)
python version 2.7 (binary from python.org)
macosx version: 10.6.4
I got the code from the "Animating selected plot elements" from the scipy cookbook page on animation.
The reason for this code is that I've several subplots to be drawn while I'm running the simulation. I could have used a simple call to plt.draw() but this would redraw the whole figure (is that right ?) and thus I tried to restrict the re-drawing to changing elements since the display is quite slow compared to simualtion.
The same code seems to be working on linux using the gtk backend but maybe it is not supposed to.
I think what is happening is that graphics context functions are being called outside of the event loop. This will not work (at least not in the Mac OS X backend), since the graphics context (CGContextRef) is initialized inside the event loop. What exactly are you trying to accomplish? Can you show a full script that you would like to use for your animations? Also, is this script shown in the matplotlib documentation somewhere?
Original report at SourceForge, opened Wed Sep 1 19:07:27 2010
setupext.py is incorrect for Mac OS X: the entry for "darwin" in the "basedir" dictionary is intentionally commented out and should be restored.
As it stands setupext.py must be edited any time one wishes to build matplotlib for Mac OS X.
Russell, I don't know how to handle this; I don't use a Mac. It is not clear to me how to how to raise an exception at an early stage, as you suggest, while still allowing setup to run from make.osx. Maybe John can either come up with an improvement, or close the bug for now.
I have no idea what was wrong that prompted you to disable darwin. All I know is that if I re-enable it and build normally then everything works well. Thus I suggest re-enabling darwin, perhaps with a warning that suggests an alternative in case the build fails.
If you are going to disable darwin I suggest you do it in a way that causes an exception with a sensible message. As it stands what happens is the build fails with mysterious errors, which is painful.
The rationale is given in setup_ext.py:
# it appears builds with darwin are broken because of all the
# different flags the deps can be compile with, so I am pushing
# people to :
# make -f make.osx fetch deps mpl_build mpl_install
Is this rationale no longer valid?
Original report at SourceForge, opened Wed Oct 6 06:04:18 2010
The tkagg backend doesn't natively support the 64-bits version of windows (not ia64 but amd64 architecture).
This is due the fact that long unsigned and __int64 are not the same types on this host.
The attached patch, based on the available commented source in src/_tkagg.cpp allows for a correct handling of Windows 64-bits platform.
There are two things to do:
verify that the new scanf format "%zu" does work on all non msvc compilers used to build matplotlib, especially older gcc versions and operating systems. I do not have the means to do this.
create a test case that fails without the patch on 64 bit Windows. I have been using mpl on win-amd64 for a year and never ran into this issue (Win 7, 8 GB RAM). From the documentation available, using size_t and "%Iu" is the correct way when using msvc. I verified that mpl still works on win32 and win-amd64 with this change.
Maybe a patch that only changes the scanf format specifier when compiled on Windows is better at this point, even though less straightforward.
if no one else have, i 'll try your patch next month.
thanks for your help
I don't have access to a 64-bit Windows installation to test with. Do any of the other developers? Any way you could get a third-party to verify that this fix works?
Regarding my patch: it is probably better to check for _MSC_VER instead of _WIN32:
-#if defined(_WIN32)
+#if defined(_MSC_VER)
forget what i said, i was thinking about soth. else.
let me know what you chose to implement.
Never heard of ptr_type and its scanf format. I got the length specifiers for size_t from Wikipedia http://en.wikipedia.org/wiki/Printf. However MSDN does not seem to know about 'I' (capital i) http://msdn.microsoft.com/en-us/library/xdb9w69d%28v=VS.90%29.aspx.
Thanks for your answer.
Then, should we not be directly using a ptr_type if we choose to adjust the sscanf format ?
This should be fixed. How about using size_t to store the pointers and adjusting the sscanf format?
--- src/_tkagg.cpp (revision 8732)
+++ src/_tkagg.cpp (working copy)
@@ -32,8 +32,12 @@
#endif
}
+#if defined(_WIN32)
+# define SIZE_T_FORMAT "%Iu"
+#else
+# define SIZE_T_FORMAT "%zu"
+#endif
typedef struct
{
PyObject_HEAD
@@ -51,7 +55,7 @@
// vars for blitting
PyObject* bboxo;
/* check for bbox/blitting */
The documentation of Tick.set_pad says
Set the tick label pad in points
but it does not seem to have any effect.
This was reported by NotBrianCox [email protected] in the user mailing list and here is his original message.
On Tue, Mar 15, 2011 at 10:43 AM, NotBrianCox [email protected] wrote:
I'm plotting a series of sub plots within a figure, where most are small sub
plots, but the last one spans the width of the figure. For the final subplot
only, I want to set the xtick pad to 20. Something like:import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(2,2,1)
ax2 = fig.add_subplot(2,2,2)
ax3 = fig.add_subplot(2,1,3)plt.setp(ax3.xaxis.get_major_ticks(), pad=20)
plt.show()But this doesn't have any effect on the final plot. I've also tried getting
the ticks individually and calling set_pad(20) i.e.:for tick in ax3.xaxis.get_major_ticks():
tick.set_pad(20)But this does't work either. Anyone have an ideas?
Apparently, set_pad only sets Tick._pad and I believe it does not have any effect unless the transform property is also updated. Also, _pad attribute is overwritten by apply_tickdir method.
I feel that the set_pad method should set "_base_pad" attribute and update the transform. Or change the documentation to state these explicitly.
Just in case, pads can be changed using the tick_params method.
ax3.tick_params(pad=20)
This sets _base_pad property and update the transform.
-JJ
It seems that people are reading the instructions at http://matplotlib.sourceforge.net/devel/coding_guide.html#using-git and trying to clone Andrew Straw's experimental git repository. The instructions should be updated to refer to git://github.com/matplotlib/matplotlib.git as the repository to clone.
the following small addition will make it possible to use explicitly named figures in pyplot.figure
Example:
plt.figure("today")
opens new or existing figure with label "today".
In windowed backends, the title of the figure window will be set to "today" instead of Figure 1.
Internally all figures remain tracked using fig.number.
The expected benefit of this patch is to make it easier to switch between multiple figures.
As I'm working through improvements to the gitwash instructions, another important piece needs to be written that existed in the old developer documentation is how to merge changes from the maintenance branches into master. I see that Darren is doing this periodically already, but the instructions should be made explicit so that a) Darren doesn't have to feel like a bottleneck in the process and b) it's usually better for the authors of the changes to merge to master themselves in case there are any conflicts or changes necessary to have them work in a different context. This is something we always encouraged during the SVN days that worked very well.
Original report at SourceForge, opened Thu Sep 23 16:12:38 2010
The levels keyword argument is completely ignored in mpl_toolkits.mplot3d.Axes3D.contour().
One suggestion might be to delete this named keyword argument altogether from the signature. A la
Axes3D.contour(self, X, Y, Z, **kwargs)
I believe this was fixed for the v1.0.0 release of mattplotlib. The function header in trunk and the maintenance branch does not have a 'level' keyword. I vaguely remember encountering this issue once.
Chances are, this will probably fall on me to address, but I am documenting it here in case someone else realizes the issue.
When creating 3d axes in the old manner (ie, ax = Axes3D(fig)), the panning and zooming features are completely useless and often produces incomprehensible results. Axes created in the newer manner (ie, ax = fig.gca(projection='3d')) has somewhat better behavior, but still quite useless.
While pan and zoom has never really been properly supported in mplot3d, the current behavior is significantly worse than before. I suspect that there might be some interactions with a variety of changes. First, there were some changes to figure object itself, which may have not been properly tested with non-subplotted axes (which would explain differences in behavior between the old style and new style). Second, I suspect that some changes to the clipping logic for Agg might be causing some of the issues with zooming and panning.
I think I will temporarily address this issue by disabling pan and zoom for Axes3D objects. I also want to make the Home button capable of returning the figure view back to normal. It does not appear to do this right now.
If I run the following example
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1,2,1)
image = plt.imread('2mass_rgb.png')
ax.imshow(image, origin='upper', extent=[0.5,723.5,0.5,724.5])
ax = fig.add_subplot(1,2,2)
image = plt.imread('2mass_rgb.jpg')
ax.imshow(image, origin='upper', extent=[0.5,723.5,0.5,724.5])
fig.savefig('rgb.png')
the left and right hand subplots show the RGB image flipped a different way. This does not happen if I use PIL to read in the image using Image.open, so presumably it is a bug in imread? The files I am using can be found here.
The following simple script:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(6, 6))
fig.savefig('line.png', dpi=40)
Produces a file that has a faint gray line one pixel wide on the left and top edges. What could be causing this, and is there a way to turn those lines off? I've uploaded the output file here
All backends should support this -- or silently convert to "nearest" in the case of raster backends.
Original report at SourceForge, opened Wed Oct 7 09:29:52 2009
The set_xticklabels() and set_yticklabels() do not work with Axes3D.
No error is issued, but it is not possible to change this information - contrary to the documentation.
(http://matplotlib.sourceforge.net/examples/mplot3d/bars3d_demo.html is a good example)
is there any way around this? we rely on mplot3d for our project (to be presented on tuesday), and the plot quality really suffers from this.
The following example illustrates an issue that occurs when using scatter
to plot circular markers in a SubplotHost instance:
import matplotlib.pyplot as plt
import mpl_toolkits.axes_grid.parasite_axes as mpltk
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.scatter([0.4],[0.5], marker='x', label='crosses')
ax.scatter([0.5],[0.5], marker='o', label='circles')
ax.scatter([0.6],[0.5], marker='^', label='arrows')
ax.set_xlim(0.,1.)
ax.set_ylim(0.,1.)
ax.legend()
fig.savefig('test_original.png')
fig = plt.figure()
ax = mpltk.SubplotHost(fig, 1, 1, 1)
fig.add_axes(ax)
ax.scatter([0.4],[0.5], marker='x', label='crosses')
ax.scatter([0.5],[0.5], marker='o', label='circles')
ax.scatter([0.6],[0.5], marker='^', label='arrows')
ax.set_xlim(0.,1.)
ax.set_ylim(0.,1.)
ax.legend()
fig.savefig('test_mpl_toolkit.png')
The circular markers do not appear in the legend when using SubplotHost.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.