Git Product home page Git Product logo

matplotlib / matplotlib Goto Github PK

View Code? Open in Web Editor NEW
19.3K 19.3K 7.4K 440.32 MB

matplotlib: plotting with Python

Home Page: https://matplotlib.org/stable/

Shell 0.02% Python 92.68% HTML 0.04% CSS 0.07% JavaScript 0.35% C++ 4.87% C 0.05% Objective-C 0.64% TeX 0.01% Jupyter Notebook 0.97% PostScript 0.02% Lua 0.01% Meson 0.26%
data-science data-visualization gtk hacktoberfest matplotlib plotting python qt tk wx

matplotlib's Introduction

PyPi Conda Downloads NUMFocus

Discourse help forum Gitter GitHub issues Contributing

GitHub actions status Azure pipelines status AppVeyor status Codecov status EffVer Versioning

Matplotlib logotype

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python.

Check out our home page for more information.

image

Matplotlib produces publication-quality figures in a variety of hardcopy formats and interactive environments across platforms. Matplotlib can be used in Python scripts, Python/IPython shells, web application servers, and various graphical user interface toolkits.

Install

See the install documentation, which is generated from /doc/install/index.rst

Contribute

You've discovered a bug or something else you want to change — excellent!

You've worked out a way to fix it — even better!

You want to tell us about it — best of all!

Start at the contributing guide!

Contact

Discourse is the discussion forum for general questions and discussions and our recommended starting point.

Our active mailing lists (which are mirrored on Discourse) are:

Gitter is for coordinating development and asking questions directly related to contributing to matplotlib.

Citing Matplotlib

If Matplotlib contributes to a project that leads to publication, please acknowledge this by citing Matplotlib.

A ready-made citation entry is available.

matplotlib's People

Contributors

afvincent avatar anntzer avatar astraw avatar blink1073 avatar cgohlke avatar ddale avatar dmcdougall avatar dopplershift avatar dstansby avatar efiring avatar ericmjl avatar greglucas avatar jdh2358 avatar jenshnielsen avatar jklymak avatar jkseppan avatar ksunden avatar leejjoon avatar mdboom avatar nellev avatar oscargus avatar pelson avatar phobson avatar qulogic avatar rcomer avatar story645 avatar tacaswell avatar timhoffm avatar tonysyu avatar weathergod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

matplotlib's Issues

urllib2/HTTPSHandler requires SSL

urllib2's HTTPSHandler requires python to have been compiled with support for SSL. For those python installs that were not, cbook is unimportable.

new feature: named figures

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.

pan and zoom are broken for mplot3d

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.

Axes3D.contour doesn't pass levels to superclass

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)

SourceForge Comments

On Mon Sep 27 23:07:14 2010, weathergod wrote:

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.

eps and useTex: tick labels drawn over legend box

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

Gray lines in empty figure

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

Problem with errorbar in log scale

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.

Circular markers plotted in SubplotHost do not appear in legend

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.

Multicursor not displayed with zoom on

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).

SourceForge Comments

On Fri Jun 4 17:32:00 2010, efiring wrote:

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.

SourceForge History

  • On Fri Jun 4 17:32:00 2010, by efiring: assigned_to: 100

Matplotlib does not display hatching when rendering to pdf

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.

improve or remove parsing of Tkinter.__version__ required for newer python versions

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

Bounding box no longer works for EPS files if usetex=True

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.

Scatter3D: arguments (c,s,...) are not taken into account

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()

SourceForge History

  • On Mon Jan 4 19:13:49 2010, by heeres: assigned_to: 100

Bug in set_view_interval

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.

Missing navigation buttons with py2exe

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.

File extension may not be the only dot in the path

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 '.'.

RGB image is flipped a different way depending on whether it is PNG or JPG

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.

dpi= doesn't seem to have any effect with MacOS X backend

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.

RuntimeError: CGContextRef is NULL with draw_artist

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

SourceForge Comments

On Tue Oct 5 02:39:48 2010, nicolasrougier wrote:

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.

On Tue Oct 5 01:31:15 2010, mdehoon wrote:

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?

SourceForge History

  • On Tue Oct 5 01:31:15 2010, by mdehoon: assigned_to: 100

mplotlib 1.0svn: alpha parameter doesn't work in 3d scatter

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.

SourceForge Comments

On Fri Jul 23 05:41:32 2010, antiw wrote:

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

On Sat Jun 19 20:49:56 2010, efiring wrote:

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.

On Wed Jun 16 23:07:11 2010, antiw wrote:

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

On Wed Jun 16 22:49:20 2010, antiw wrote:

Correct: The scatter is always displayed as alpha is None (in version 1.0, they set the default value of alpha None)

SourceForge History

  • On Sat Jun 19 20:49:56 2010, by efiring: assigned_to: 100

Axes3D.scatter ignores kwargs

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

SourceForge History

  • On Mon Jan 4 19:16:57 2010, by heeres: assigned_to: 100

unexpected dates from drange

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

setupext.py incorrect for Mac OS X

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.

SourceForge Comments

On Sat Oct 9 20:59:36 2010, efiring wrote:

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.

On Fri Sep 10 12:45:41 2010, reowen wrote:

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.

On Sat Sep 4 20:57:59 2010, efiring wrote:

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?

SourceForge History

  • On Sat Oct 9 20:59:36 2010, by efiring: assigned_to: 100

Sphinx plot extension source/build directory issues

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:

  1. 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.

  2. 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.

SourceForge Comments

On Sun Dec 5 16:22:05 2010, weegreenblobbie wrote:

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:

Add any Sphinx extension module names here, as strings. They can be extensions

coming with Sphinx (named 'sphinx.ext.*') or your custom ones.

extensions =
[
'sphinxext.mathmpl',
'sphinxext.only_directives',
'sphinxext.plot_directive',
'sphinx.ext.autodoc',
'sphinx.ext.doctest'
]

And inlined plot directive work.

On Mon Jul 12 18:10:13 2010, None wrote:

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:

On Thu Jun 17 08:42:55 2010, cmcqueen1975 wrote:

Yes, Sphinx 1.0b2.

On Wed Jun 16 15:59:08 2010, mdboom wrote:

Which version of Sphinx? I believe you may get this message with Sphinx1.0b2.

bbox_inches='tight' raises KeyError for JPG and TIF

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

Issue with single contour level in contourf

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

mplot3d scatter should filter NaN values out

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.

SourceForge History

  • On Sun May 30 15:09:16 2010, by efiring: assigned_to: 100

dpi in savefig ignored if imshow uses interpolation='nearest'

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

twinx and plot_date

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])

This will fail

fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax2 = ax1.twinx()

ax2.plot_date(tarr, varr)

fig.canvas.draw()

SourceForge Comments

On Fri Oct 22 10:55:06 2010, leejjoon wrote:

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.

On Tue Aug 17 02:18:10 2010, pzakielarz wrote:

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.

error DraggableOffsetBox with offsetbox._offset

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.

SourceForge Comments

On Sat Sep 4 22:03:42 2010, leejjoon wrote:

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

On Sat Sep 4 17:48:04 2010, efiring wrote:

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.

SourceForge History

  • On Sat Sep 4 21:58:28 2010, by leejjoon: File Added: 385636: fix_draggable_legend.diff
  • On Sat Sep 4 17:48:05 2010, by efiring: assigned_to: 100

Tick.set_pad does not work

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

arrow command broken

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 text.usetex=True with pdf backend, full subset of latex fonts is embedded into pdf file

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.

Autoscale in hist() with step and log

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)

SourceForge Comments

On Wed Aug 4 10:24:05 2010, None wrote:

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.

On Tue Jul 6 15:17:38 2010, mdboom wrote:

Can you be more specific about what you would have expected to see?

On Tue Jun 29 08:05:07 2010, None wrote:

Uploaded the plot that I get here, from rev 8475.

On Thu Jun 24 10:51:32 2010, mdboom wrote:

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.

SourceForge History

  • On Tue Jun 29 03:22:58 2010, by None: File Added: 378710: image.png

plot_directive failures

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.

Instructions on merging maintenance branches

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.

Cannot set tick labels for Axes3D

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)

SourceForge Comments

On Fri Feb 25 08:59:05 2011, flying-sheep wrote:

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.

SourceForge History

  • On Mon May 31 21:37:43 2010, by efiring: assigned_to: 100

scatter should accept '*' as markerstyle (the way plot does)

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>]

test suite yields errors instead of failures

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.

windows x64 support in _tkagg.so

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.

SourceForge Comments

On Tue Oct 19 14:38:50 2010, cjgohlke wrote:

There are two things to do:

  1. 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.

  2. 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.

On Tue Oct 19 12:21:08 2010, oeloio wrote:

if no one else have, i 'll try your patch next month.
thanks for your help

On Tue Oct 19 11:04:06 2010, mdboom wrote:

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?

On Thu Oct 7 14:25:23 2010, cjgohlke wrote:

Regarding my patch: it is probably better to check for _MSC_VER instead of _WIN32:

-#if defined(_WIN32)
+#if defined(_MSC_VER)

On Thu Oct 7 02:55:09 2010, oeloio wrote:

forget what i said, i was thinking about soth. else.
let me know what you chose to implement.

On Thu Oct 7 02:50:40 2010, cjgohlke wrote:

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.

On Thu Oct 7 01:53:50 2010, oeloio wrote:

Thanks for your answer.
Then, should we not be directly using a ptr_type if we choose to adjust the sscanf format ?

On Wed Oct 6 22:29:41 2010, cjgohlke wrote:

This should be fixed. How about using size_t to store the pointers and adjusting the sscanf format?

Index: src/_tkagg.cpp

--- 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;

  • unsigned long aggl, bboxl;
  • size_t aggl, bboxl;
    bool has_bbox;
    agg::int8u destbuffer;
    double l, b, r, t;
    @@ -81,7 +85,7 @@
    return TCL_ERROR;
    }
    /
    get array (or object that can be converted to array) pointer */
  • if (sscanf(argv[2], "%lu", &aggl) != 1)
  • if (sscanf(argv[2], SIZE_T_FORMAT, &aggl) != 1)
    {
    Tcl_AppendResult(interp, "error casting pointer", (char *) NULL);
    return TCL_ERROR;
    @@ -107,7 +111,7 @@
    }

/* check for bbox/blitting */

  • if (sscanf(argv[4], "%lu", &bboxl) != 1)
  • if (sscanf(argv[4], SIZE_T_FORMAT, &bboxl) != 1)
    {
    Tcl_AppendResult(interp, "error casting pointer", (char *) NULL);
    return TCL_ERROR;

SourceForge History

  • On Sat Oct 9 20:07:44 2010, by efiring: assigned_to: 100
  • On Wed Oct 6 06:04:19 2010, by oeloio: File Added: 389037: patch_wx64_tkagg.diff

Axes3d Scatter: Color and Size don't work

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)

SourceForge Comments

On Wed Mar 16 05:28:24 2011, None wrote:

The problem seems to be present still in version 1.0.1 but 1.1.0svn seems to work correctly.

On Sun May 23 12:33:25 2010, jskowron wrote:

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.

SourceForge History

  • On Mon Jan 4 19:17:21 2010, by heeres: assigned_to: 100

set_rubberband: integer argument expected, got float

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.