juliapy / pyplot.jl Goto Github PK
View Code? Open in Web Editor NEWPlotting for Julia based on matplotlib.pyplot
Home Page: https://github.com/JuliaPy/PyPlot.jl
License: MIT License
Plotting for Julia based on matplotlib.pyplot
Home Page: https://github.com/JuliaPy/PyPlot.jl
License: MIT License
Would be nice to have some documentation, and examples in README.md so that one can get started with some simple stuff. I am currently looking at the tests to see how to use this package.
Hi there,
It seems that I get an empty plot when I try to plot row vectors. Do others see this behavior or is it maybe on purpose?
: Produce correct plot:
x = [1.0:10.0];
y = x.*x;
plot(x,y)
: Produce empty plot:
x = [1.0:10.0]';
y = x.*x;
plot(x,y)
Versioninfo:
Julia Version 0.2.0
Commit 05c6461 (2013-11-16 23:44 UTC)
Platform Info:
System: Darwin (x86_64-apple-darwin12.5.0)
WORD_SIZE: 64
BLAS: libgfortblas
LAPACK: liblapack
LIBM: libopenlibm
I'm using PyPlot 1.0.12+ (master)
Best,
Oliver
Hi,
Reporting a crash during using PyPlot
.
Config:
Steps to reproduce:
using PyCall
using PyPlot
Error message:
ImportError: No module named site
Other infos:
C:\Users\cmey\Downloads\Julia 0.3.0-prerelease>python
Enthought Canopy Python 2.7.6 | 64-bit | (default, Apr 11 2014, 20:31:44) [MSC v
.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from matplotlib.pyplot import *
>>> plot([1,2],[3,4])
[<matplotlib.lines.Line2D object at 0x000000000788A630>]
The problem is based on the way that julia distinguishes between singleton arrays and nx1 two-dimensional arrays. The optional argument zs
for plot3D( xs, ys, zs=zs )
is not robust to these two different representations but the first two arguments xs, ys
are.
Say a matrix of data is generated and three sets of points for plotting are extracted from the columns of the matrix:
mat = [ 1 4 7;2 5 8;3 6 9 ]
x = mat[ :,1 ]
y = mat[ :,2 ]
z = mat[ :,3 ]
Each vector x, y, z
is a 3-element Array{Int64,1}
. These can be plotted using:
using PyPlot
close( gcf() )
plot3D( x, y, zs=z )
display( gcf() )
However, say the matrix is transposed and the rows are spliced and transposed:
x = mat'[ 1,: ]'
y = mat'[ 2,: ]'
z = mat'[ 3,: ]'
Each vector is now a 3x1 Array{Int64,2}
and plotting as above gives:
using PyPlot
close( gcf() )
plot3D( x, y, zs=z )
display( gcf() )
PyError (PyObject_Call) <type 'exceptions.ValueError'>
ValueError('could not broadcast input array from shape (3,1) into shape (3)',)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/backend_bases.py", line 2177, in print_figure
**kwargs)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/backends/backend_agg.py", line 509, in print_png
FigureCanvasAgg.draw(self)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/backends/backend_agg.py", line 455, in draw
self.figure.draw(self.renderer)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/figure.py", line 1050, in draw
func(*args)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/mpl_toolkits/mplot3d/axes3d.py", line 275, in draw
Axes.draw(self, renderer)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/axes/_base.py", line 2076, in draw
a.draw(renderer)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/mpl_toolkits/mplot3d/art3d.py", line 124, in draw
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/mpl_toolkits/mplot3d/proj3d.py", line 198, in proj_transform
vec = vec_pad_ones(xs, ys, zs)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/mpl_toolkits/mplot3d/proj3d.py", line 187, in vec_pad_ones
vec = np.array([xs,ys,zs,np.ones(xs.shape)])
while loading In[16], in expression starting on line 4
in pyerr_check at /Users/user/.julia/v0.3/PyCall/src/exception.jl:58
in pycall at /Users/user/.julia/v0.3/PyCall/src/PyCall.jl:85
in fn at /Users/user/.julia/v0.3/PyCall/src/conversions.jl:181
in writemime at /Users/user/.julia/v0.3/pyplot/src/pyplot.jl:140
in base64 at base64.jl:125
in display_dict at /Users/user/.julia/v0.3/IJulia/src/execute_request.jl:30
in display at /Users/user/.julia/v0.3/IJulia/src/inline.jl:34
in display at multimedia.jl:150
Clearly Plot3D cannot handle this difference well. However, it turns out that the required arguments xs, ys
are robust to this whereas zs
is not. Using the 3x1 Array{Int64,2}
vectors again:
using PyPlot
close( gcf() )
plot3D( x, y )
display( gcf() )
Works fine.
Sorry for the very contrived example but this caused me some confusion earlier!
Thanks
LightTable has support for matplotlib inline plots, I was wondering how to get them to display using PyPlot. In fact I cannot even get it to show a separate plot window atm.
I'm using LightTable with the Jewel plugin and Jupiter environment.
It would be great to register this package with METADATA.jl, so that people can get it with Pkg.add("pyplot")
.
Working with the ZMQ provided through Pkg, I get:
julia> figure()
ERROR: no method send(ZMQSocket,ASCIIString)
in send at /Users/viral/.julia/PyPlot/src/aux.jl:61
in figure at /Users/viral/.julia/PyPlot/src/wrap.jl:14
I then checked out the ZMQ master and figure()
just hangs. I am on OS X 10.8.4
I discovered something strange when using plot from PyPlot:
julia> 1.0
1.0
julia> using PyPlot
julia> 1.0
1.0
julia> plot([1,2,3])
1-element Any Array:
PyObject <matplotlib.lines.Line2D object at 0x62390d0>
julia> 1.0
ERROR: syntax: invalid numeric constant 1.0
Any ideas?
Version info:
Julia Version 0.2.0-prerelease+3183
Commit 8752713 2013-08-12 13:11:09 UTC
Platform Info:
System: Linux (x86_64-linux-gnu)
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY)
LAPACK: libopenblas
LIBM: libopenlibm
When I execute a cell containing
fig, ax = subplots(3,3)
I get a pop-up saying "Kernel Restarting: The kernel appears to have died. It will restart automatically."
Do you think it's possible to support the MacOSX backend?
the issue comes up often enough, that i wonder whether it's worth being more explicit. specifically, saying that on OS X, you can not use the default python install, even though it has matplotlib, because it does not use Qt. rather you should install a second copy of python using homebrew. on 10.9 mavericks do as follows:
brew install python
export PATH="/usr/local/bin:$PATH"
export PYTHONPATH=/usr/local/lib/python2.7
pip install numpy
brew install gfortran
pip install scipy
brew install pyqt
brew install freetype
ln -s /usr/local/Cellar/freetype/2.5.3_1/include/freetype2/ /usr/local/include/freetype
pip install matplotlib
It would be good if the package could check for the python dependencies when it is loaded. I did not have pyzmq
and it just hung.
I'm not sure of the root cause, but compare:
function f()
ax = subplot(1, 1, 1)
ax[:plot](1:10, 1:10)
end
f()
and
function g()
ax = subplot(1, 1, 1)
pmap(x->(), 1:1)
ax[:plot](1:10, 1:10)
end
g()
With f
, I get the expected plot. With g
, a window opens but it the plot is never shown.
Hello,
I use Ubuntu 12.04, 64 bit.
I installed the newest matplotlib version with pip:
sudo pip install -U matplotlib
It works fine in python.
But I cannot import it from Julia 0.2.
using PyPlot results in the following error message:
ulia> using PyPlot
LoadError("/home/ufechner/.julia/PyPlot/src/PyPlot.jl",32,PyError (PyImport_ImportModule) <type 'exceptions.ImportError'>
ImportError('cannot import name scimath',)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/init.py", line 156, in
from matplotlib.cbook import is_string_like
File "/usr/local/lib/python2.7/dist-packages/matplotlib/cbook.py", line 28, in
import numpy as np
File "/usr/local/lib/python2.7/dist-packages/numpy/init.py", line 153, in
from . import add_newdocs
File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/init.py", line 17, in
from . import scimath as emath
)
julia>
Any idea?
Uwe
I complied Julia under Archlinux. Successfully added PyPlot package, but failed in loading it:
julia> using(PyPlot)
ERROR: PyError (PyImport_ImportModule) <class 'ImportError'>
ImportError("No module named 'matplotlib'",)
in pyerr_check at /home/hellolj/.julia/PyCall/src/exception.jl:58
in pyimport at /home/hellolj/.julia/PyCall/src/PyCall.jl:85
in reload_path at loading.jl:146
in _require at loading.jl:59
in require at loading.jl:43
while loading /home/hellolj/.julia/PyPlot/src/PyPlot.jl, in expression starting on line 32
I suspect that this error happened because under Arch Linux, ipython 2.7 is named ipython2 insteady of ipython by default on Julia side.
Can anyone help with this issue?
Thanks,
Is there a way to embed plots within a PySide GUI? I can follow along with http://wiki.scipy.org/Cookbook/Matplotlib/PySide to create the fig object and can draw on that, but don't know how to set that fig object to be the active figure that PyPlot.jl's exported plot commands use. Is there something like manager["canvas"]"setFigure"? I don't see that symbol in the manager["canvas"] object.
Maybe I'm going about this wrong. Any help would be appreciated.
hist does not seem to plot anything; it just returns the computed histogram. (it's supposed to do both)
this is using PyCall from Terminal.app on OSX. plot() works fine.
julia> using PyPlot
Fatal Python error: no mem for sys.argv
ValueError: character U+ffffff00 is not in range [U+0000; U+10ffff]
[1] 11996 abort (core dumped) julia
It happened randomly. Seems like occured when using @pyimport
.
OS: ArchLinux
Julia: latest, Commit makepkg/2200bd3 2013-08-09 00:03:02 UTC
PyCall, PyPlot: latest
Python: 3.3
I have been using PyPlot for a few days now and it worked flawlessly until yesterday, when the package stopped producing plots. I have no idea why this happened as I don't recall me making any updates etc. The example from README, when I input it in the REPL, results in the following output (there are no errors), but no window pops up.
julia> using PyPlot
julia> x = linspace(0,2*pi,1000); y = sin(3*x + 4*cos(2*x));
julia> plot(x, y, color="red", linewidth=2.0, linestyle="--")
1-element Array{Any,1}:
PyObject <matplotlib.lines.Line2D object at 0x7f7882c8feb8>
julia> title("A sinusoidally modulated sinusoid")
PyObject <matplotlib.text.Text object at 0x7f7882cde198>
I am using Archlinux, Julia Version 0.3.0-prerelease+2954 and PyPlot from master.
I am trying to "connect" to PyPlot events so I can visually inspect some plots and extract peaks from 1D spectra.
I tried the following
julia> using PyPlot
'import sitecustomize' failed; use -v for traceback
julia> x = Float64[]; y = Float64[]
0-element Array{Float64,1}
julia> function mycall(event)
append!(x,[event.xdata]); append!(y,[event.ydata])
end
mycall (generic function with 1 method)
julia> connect("button_press_event", mycall)
ERROR: PyError (PyObject_Call) <type 'exceptions.TypeError'>
TypeError("cannot create weak reference to 'PyCall.jl_Function' object",)
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.py", line 395, in connect
return get_current_fig_manager().canvas.mpl_connect(s, func)
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2195, in mpl_connect
return self.callbacks.connect(s, func)
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/cbook.py", line 308, in connect
self._func_cid_map[s][func] = cid
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 262, in __setitem__
self.data[ref(key, self._remove)] = value
in pyerr_check at /Users/msilva/.julia/PyCall/src/exception.jl:58
in pycall at /Users/msilva/.julia/PyCall/src/PyCall.jl:85
in connect at /Users/msilva/.julia/PyPlot/src/PyPlot.jl:235
Looking through the PyPlot code it seems like connect
should work in this instance, but I have not been able to find any examples of people using this function, so I am not sure if it is functional.
Possibly related with issue #28, since two days ago started getting the following error on Windows (same error in Ijulia and Julia console)
using PyPlot
ImportError: No module named site
WARNING:
could not load module python: The specified module could not be found.
at C:\Users\Tony\.julia\PyPlot\src\PyPlot.jl:32
at In[1]:2
in pyinitialize at C:\Users\Tony\.julia\PyCall\src\PyCall.jl:419
Matplotlib is working fine from python. However after using PyCall; @pyimport matplotlib
getting the same error
ImportError: No module named site
WARNING:
could not load module python: The specified module could not be found.
in pyinitialize at C:\Users\Tony\.julia\PyCall\src\PyCall.jl:419
in pyinitialize at C:\Users\Tony\.julia\PyCall\src\PyCall.jl:416
I have a plot where the function values range over a quite small range relative to how far away from zero they are, resulting in PyPlot showing the y-axis with tick offsets, just as described in this SO question.
I tried to adapt that solution to my script:
plot((psi.-psimin)./(psimax-psimin),F)
gca()[:get_xaxis]()[:get_major_formatter]()[:set_useOffset](false)
draw()
but the two last rows don't seem to affect the plot at all. I thought this might be because PyPlot somehow eliminates the need to call draw
, so that's already done through plot
, but moving the gca()[...
stuff above the plot
call doesn't work either.
Is there a way to make this work?
I got a 64bit debian installed over a virtual machine
when I try to load PyPlot I get the following
julia> using PyPlot
Loading help data...
ERROR: syntax: invalid numeric constant 0.5
in include at boot.jl:238
at /home/pog/.julia/Color/src/Color.jl:211
at /home/pog/.julia/PyPlot/src/colormaps.jl:4
at /home/pog/.julia/PyPlot/src/PyPlot.jl:278
of course I have installed matplotlib.
When I try to use it the 'plot' function is working well, while on the other hand the function 'surf' has not been imported.
I appreciate any suggestion...
I have my matplotlibrc file tweaked to use nicer default colors for my plots. PyPlot does not seem to be reading matplotlibrc and instead uses the normal defaults. Is there a way to read matplotlibrc? If so then it could be used to select the backend as well (as long as MacOSX is supported for Mac).
Currently, if PyPlot uses PyCall's pygui()
, it lets pygui()
pick the first supported toolkit that is installed for Python. However, if the toolkit was installed after matplotlib, it looks like matplotlib may need to be rebuilt in order to include that toolkit's backend.
For example, now that PyCall has switched its default GUI to Qt rather than wx, @bkalpert reported the following error:
julia> using PyPlot
ERROR: PyError (PyImport_ImportModule) <type 'exceptions.ImportError'>
ImportError('No module named backend_qt4agg',)
File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 97, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
in pyerr_check at /home/alpert/.julia/PyCall/src/exception.jl:58
in pyimport at /home/alpert/.julia/PyCall/src/PyCall.jl:85
in include_from_node1 at loading.jl:92
in reload_path at loading.jl:117
in require at loading.jl:48
at /home/alpert/.julia/PyPlot/src/PyPlot.jl:49
Hi there,
I'm trying to create a 3D Surface plot and label + limit the three Axes (x, y, z), however it looks as though matplotlib's set_zlabel
and set_zlim
options are not exposed through PyPlot.
Below is the code I've got thus far - any help would be greatly appreciated!
plot_surface(x, y, z, color="green")
xlabel("x")
ylabel("y")
ylim([1,10])
xlim([1,10])
# How do I add a label and limit to the z-axis?
Thanks!
I get the following error when trying to use PyPlot:
ERROR: key not found: "plot_trisurf"
in getindex at /home/esben/.julia/PyCall/src/PyCall.jl:582
in anonymous at no file:312
in include at boot.jl:240
in include_from_node1 at loading.jl:120
in reload_path at loading.jl:146
in _require at loading.jl:59
in require at loading.jl:43
while loading /home/esben/.julia/PyPlot/src/PyPlot.jl, in expression starting on line 305
I have matplotlib installed and tested it from the python terminal and it works just fine.
I am running Julia v.0.3.0-prerelease
On @JeffBezanson's computer, whenever he makes a new plot with PyPlot, an empty window pops up.
Using PyPlot from IJulia (which works fine) I receive the following error when attempting to execute the "Basic Usage" example.
gui not defined
at /home/edmund/.julia/PyPlot/src/PyPlot.jl:41
at In[2]:1
in anonymous at no file:75
in include_from_node1 at loading.jl:92
in reload_path at loading.jl:117
in require at loading.jl:48
/home/edmund/anaconda/lib/python2.7/site-packages/matplotlib/init.py:1033: UserWarning: This call to matplotlib.use() has no effect
because the the backend has already been chosen;
matplotlib.use() must be called before pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
warnings.warn(_use_error_msg)
Running Pkg.add("PyPlot") in a fresh install of Julia 0.2.1 gives the following error:
~ $ rm -rf ~/.julia
~ $ julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" to list help topics
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.2.1 (2014-02-11 06:30 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-apple-darwin12.5.0
julia> Pkg.add("PyPlot")
INFO: Initializing package repository /Users/travis/.julia/v0.2
INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl
INFO: Cloning cache of Color from git://github.com/JuliaLang/Color.jl.git
INFO: Cloning cache of PyCall from git://github.com/stevengj/PyCall.jl.git
INFO: Updating cache of PyCall...
INFO: Cloning cache of PyPlot from git://github.com/stevengj/PyPlot.jl.git
INFO: Updating cache of PyPlot...
ERROR: Missing package versions (possible metadata misconfiguration): PyCall v(nothing,v"0.4.4") [fef614152839357e9ca27e55c97fc33f33f301d3[1:10]]
PyPlot v(nothing,v"1.2.5") [a4e224a427aa997304d9a6da9a889c8bbfc681da[1:10]]
in error at error.jl:21
in resolve at pkg/entry.jl:350
in resolve at pkg/entry.jl:316
in edit at pkg/entry.jl:24
in add at pkg/entry.jl:44
in add at pkg/entry.jl:48
in anonymous at pkg/dir.jl:28
in cd at file.jl:22
in cd at pkg/dir.jl:28
in add at pkg.jl:19
I'd like to replace this with a version based on PyCall, which allows one to call the full Matplotlib interface directly, with no-copy passing of large arrays. (I have a prototype in the IJulia source, which integrates directly with the IJulia backend as well as with future pure-Julia graphics backends).
How would you feel about this?
When calling plot3d
with three 1D arrays e.g. plot3D( x,y,z )
the following error occurs:
PyError (PyObject_Call) <type 'exceptions.ValueError'>
ValueError(u'third arg must be a format string',)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/mpl_toolkits/mplot3d/axes3d.py", line 1518, in plot
lines = Axes.plot(self, xs, ys, *args[argsi:], **kwargs)
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/axes/_axes.py", line 1333, in plot
for line in self._get_lines(*args, **kwargs):
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/axes/_base.py", line 303, in _grab_next_args
for seg in self._plot_args(remaining, kwargs):
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/axes/_base.py", line 265, in _plot_args
raise ValueError('third arg must be a format string')
It seems to want a call of the form plot3D( xs,yz,*args,*kwargs )
as in the Python documentation for mplot3d [ http://matplotlib.org/dev/mpl_toolkits/mplot3d/tutorial.html ] but is this incorrect? The accompanying python example on that webpage calls using ax.plot( x,y,z,label="parametric curve" )
I should add, the exact call I am using is plot3D( y[ 1,: ]', y[ 2,: ]', y[ 3,: ]' )
Prettyplotlib is a wrapper for matplotlib with a focus on more beautiful graphics, http://olgabot.github.io/prettyplotlib/
It would be nice if PyPlot would use it if its available.
PyPlot exports variants of step
and show
that shadow the methods from Base
. I see there's special handling to avoid overriding the Base
methods for close
, connect
, and fill
, but it would be great to handle these as well.
I have no problem running this:
contour(1:10,1:10,rand(10,10))
but that fails:
contour(1:9,1:10,rand(10,9))
is this expected?
When used from the IJulia notebook, PyPlot has recently started displaying duplicated figures. The first commit in Julia for which this is a problem is JuliaLang/julia@737ad6e.
This issue affects at least one other user (see https://groups.google.com/forum/#!topic/julia-users/_j2oPxdSu0I).
Gadfly in IJulia and matplotlib in IPython are allegedly not affected, so I'm reporting this issue here.
I observe this using Julia compiled on 64-bit Ubuntu 14.04, with Firefox. I am on PyPlot commit 1c2d22e.
I'm receiving the following error:
julia> using PyPlot
WARNING: No working GUI backend found for matplotlib.
Fontconfig warning: ignoring UTF-8: not a valid region tag
Fontconfig warning: ignoring UTF-8: not a valid region tag
I'm on OSX 10.9, and Julia v0.2.0 and I've installed PySide (also tried PyQt) through Homebrew. The GUI backend works fine through the Python terminal.
I'm curious on how to resolve this issue?
Thanks for the help.
Example: When I create an xkcd-style plot using PyPlot.jl (see https://gist.github.com/cmundi/9041366) in a fresh session of IJulia, I get this error:
/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['Humor Sans', 'Comic Sans MS'] not found. Falling back to Bitstream Vera Sans
(prop.get_family(), self.defaultFamily[fontext]))
Ok, so matplotlib apparently cannot find the Comic Sans font. That makes sense, because I don't see that font in /usr/share/fonts/truetype. But hold on a second! If I run the usual examples of xkcd in IPython (not IJulia) the comic sans fonts render in the plots -- no problem! Just for fun I installed the MS fonts which include Comic_Sans_MS.ttf and rebuilt the cache with
fc-cache -rv
which picked up the new fonts. Started a new session of IJulia and... no comic sans for xkcd... still gives me the fallback sans serif fonts.
I would say this is a font config problem (with IPython finding Comic Sans and IJulia not finding it) but that seems strange since PyPlot.jl is a wrapper around matplotlib. Any ideas?
Yes, I know, I should be making a useful contribution to society instead of worrying about xkcd. :)
Thanks.
Something in the past few weeks has made PyPlot unusable. I'm on PyCall v0.4.5, PyPlot v1.2.5, and PySide v0.0.2.
in the julia terminal:
julia> using PyPlot
ERROR: PyError (PyImport_ImportModule)
in pyerr_check at /Users/joshua/.julia/PyCall/src/exception.jl:58
in pyimport at /Users/joshua/.julia/PyCall/src/PyCall.jl:85
in pyinitialize at /Users/joshua/.julia/PyCall/src/PyCall.jl:259
in pyinitialize at /Users/joshua/.julia/PyCall/src/PyCall.jl:447
in pyimport at /Users/joshua/.julia/PyCall/src/PyCall.jl:105
in reload_path at loading.jl:152
in _require at loading.jl:67
in require at loading.jl:51SYSTEM: show(lasterr) caused an error
in Ijulia:
In[*]: using PyPlot
KERNEL EXCEPTION
access to undefined reference
in convert at /Users/joshua/.julia/PyCall/src/conversions.jl:82
in pystring at /Users/joshua/.julia/PyCall/src/PyCall.jl:542
in show at /Users/joshua/.julia/PyCall/src/exception.jl:35
in showerror at replutil.jl:66
in showerror at replutil.jl:74 (repeats 2 times)
in showerror at replutil.jl:72
in sprint at io.jl:460
in pyerr_content at /Users/joshua/.julia/IJulia/src/execute_request.jl:66
_
_ _ ()_ | A fresh approach to technical computing
() | () () | Documentation: http://docs.julialang.org
_ _ | | __ _ | Type "help()" to list help topics
| | | | | | |/ ` | |
| | || | | | (| | | Version 0.3.0-prerelease+2570 (2014-04-09 19:29 UTC)
/ |_'|||__'| | Commit 4fc2a15 (34 days old master)
|__/ | x86_64-apple-darwin13.1.0
In ipython notebook,
i do the following
using PyPlot
xkcd()
and got this error
sf not defined
while loading In[6], in expression starting on line 1
I am new to julia and just installed it yesterday together with PyPlot. But whenever I am trying to plot something using plot I am getting
julia> Segmentation fault (core dumped)
The plot window is coming but it hanged . Please advice me. I checked PyCall and matplotlib, both are working fine.
On julia.mit
, PyPlot
produces PyObject
output in IJulia instead of plots. This is apparently caused by having Qt support compiled into matplotlib, so that the backend defaulted to Qt4Agg
even in IJulia. Hacking PyPlot
to force the backend to Agg
got the plots working again in IJulia.
Perhaps in the backend detection code PyPlot
could check if it is running in IJulia, e.g. with isdefined(Main, :IJulia)
, and always run the fallback lines in IJulia.
Hi,
I have posted this issue also in the IJulia repository, but they are not sure, if this might be an PyPlot issue, so I am reposting it here.
The post can be followed here:
And this was my original post:
I am using IJulia 0.1.12 with PyPlot 1.2.7 on Mac OS X 10.9.3, Safari 7.0.4 and julia 0.3.0-prerelease+3679
The following lines work well when I call them from the command line:
using PyPlot
plot(rand(10))
but give me the following errors, when I call them from within IJulia:
INFO: Loading help data...
PyError (PyObject_Call)
RuntimeError('Could not create write struct',)
File "/usr/local/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2167, in print_figure
**kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 517, in print_png
filename_or_obj, self.figure.dpi)
in pyerr_check at /Users/me/.julia/v0.3/PyCall/src/exception.jl:58
in pycall at /Users/me/.julia/v0.3/PyCall/src/PyCall.jl:85
in fn at /Users/me/.julia/v0.3/PyCall/src/conversions.jl:181
in writemime at /Users/zahmeedi/.julia/v0.3/PyPlot/src/PyPlot.jl:141
in base64 at base64.jl:125
in display_dict at /Users/me/.julia/v0.3/IJulia/src/execute_request.jl:34
in display at /Users/me/.julia/v0.3/IJulia/src/inline.jl:35
in display at multimedia.jl:149
in display at /Users/me/.julia/v0.3/IJulia/src/inline.jl:56
A StackOverflow question today raised the issue that if PyPlot is run from a script, the plot is never displayed: the plot call returns, and Julia immediately exits.
One thought I had was to override show(::Figure)
and block there pending user input, but ideally only the final plot in the script should block.
I was expecting to be able to do
open(file->writemime(file,"image/png",PyPlot.streamplot(args...)),"test.png","w"))
In order to save a PyPlot plot (this works for e.g. Gadfly/Winston). Any chance that could be supported?
I just grabbed the latest Julia: Julia-0.2.0-pre-7530d98cfd
since 2.0 was required.
After installing with Pkg.add("PyPlot") i get the following
julia> using PyPlot
Warning: could not import Base.writemime into PyPlot
ERROR: displayable not defined
in isdisplayok at /Users/ob/.julia/PyPlot/src/PyPlot.jl:18
in include_from_node1 at loading.jl:92
in reload_path at loading.jl:117
in require at loading.jl:48
Am I missing some version missmatch?
I tried
PyPlot.hist2d(rand(10),rand(10))
but get an error:
m not defined
while loading In[13], in expression starting on line 1
in hist2d at /Users/solver/.julia/PyPlot/src/PyPlot.jl:243
For some methods where matplotlib
use strings, PyPlot
uses symbols, which IMO makes the Julia code look much prettier =) For example, to set the scaling of the axes in Julia, I do axis(:equal)
, axis(:scaled)
etc.
However, some methods that I expected to work the same didn't - for example, close
takes a regular string: close("all")
works, but close(:all)
doesn't.
In my current session, I can't find a conflict that makes it unfeasible to overload on Symbol
- nothing else (that I happen to have imported at the moment) does:
julia> methods(close)
#12 methods for generic function "close":
close(io::IOBuffer) at iobuffer.jl:155
close(b::Base64Pipe) at base64.jl:110
close(s::IOStream) at io.jl:265
close(t::Timer) at stream.jl:446
close(stream::Union(AsyncStream,UVServer)) at stream.jl:584
close(f::File) at fs.jl:84
close(d::TextDisplay) at multimedia.jl:122
close(t::FileMonitor) at poll.jl:22
close(t::UVPollingWatcher) at poll.jl:236
close(s::GZipStream) at /home/tlycken/.julia/v0.3/GZip/src/GZip.jl:294
close(f::Union(Figure,String,Integer)) at /home/tlycken/.julia/v0.3/PyPlot/src/PyPlot.jl:268
close() at /home/tlycken/.julia/v0.3/PyPlot/src/PyPlot.jl:269
There might be other cases as well, other than close
. I suggest letting them all take Symbol
arguments as well for consistency and overall prettiness.
Would it be possible for someone to add an example of using PyPlot.jl to create an xkcd style plot? I see references to xkcd in PyPlot.jl but I'm not smart enough (and new to matplotlib) to figure it out for myself. Thanks.
Although I am able to install PyPlot
, I get an error message when importing it into a Julia session:
julia> Pkg.update()
INFO: Initializing package repository /home/carlos/.julia.
INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl
INFO: Updating METADATA...
INFO: Computing changes...
INFO: No packages to install, update or remove.
julia> Pkg.add("PyPlot")
INFO: Cloning cache of PyPlot from git://github.com/stevengj/PyPlot.jl.git
INFO: Cloning cache of Color from git://github.com/JuliaLang/Color.jl.git
INFO: Cloning cache of PyCall from git://github.com/stevengj/PyCall.jl.git
INFO: Installing PyPlot v1.0.11
INFO: Installing Color v0.2.6
INFO: Installing PyCall v0.0.0
INFO: REQUIRE updated.
julia> using PyPlot
ERROR: PyError (PyImport_ImportModule) <type 'exceptions.AttributeError'>
AttributeError("'module' object has no attribute 'core'",)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 129, in <module>
from matplotlib.cbook import is_string_like
File "/usr/local/lib/python2.7/dist-packages/matplotlib/cbook.py", line 28, in <module>
import numpy as np
File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 13, in <module>
from polynomial import *
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/polynomial.py", line 11, in <module>
import numpy.core.numeric as NX
in pyerr_check at /home/carlos/.julia/PyCall/src/exception.jl:58
in pyimport at /home/carlos/.julia/PyCall/src/PyCall.jl:85
in include at boot.jl:238
in include_from_node1 at loading.jl:96
in reload_path at loading.jl:121
in require at loading.jl:50
at /home/carlos/.julia/PyPlot/src/PyPlot.jl:32
julia>
How can I get PyPlot
up and running?
I am running:
python 2.7.3
matplotlib 1.3.0
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.