Comments (6)
@cnuernber , My project is here: https://github.com/chanshunli/matplotlib-clj :-D
from libpython-clj.
Hmm. I don't think this is fixable from the outside. Probably you will need to use the canvas renderers for matplotlib or only use it from the main thread, not a repl thread (which would be a shame).
Good idea for a project though.
from libpython-clj.
I run this plot in lein run
,not other thread :
坚持去λ化(eshell) matplotlib-clj master $ lein run
十一月 16, 2019 12:20:10 上午 clojure.tools.logging$eval486$fn__489 invoke
信息: executing python initialize!
十一月 16, 2019 12:20:10 上午 clojure.tools.logging$eval486$fn__489 invoke
信息: Library /usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib found at [:system "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib"]
十一月 16, 2019 12:20:10 上午 clojure.tools.logging$eval486$fn__489 invoke
信息: Reference thread starting
2019-11-16 00:20:11.618 java[997:1376858] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
0 AppKit 0x00007fff2c69e6ef -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 371
1 AppKit 0x00007fff2c69bbc1 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
2 AppKit 0x00007fff2c69b633 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
3 _macosx.cpython-37m-darwin.so 0x000000012ca016b0 -[Window initWithContentRect:styleMask:backing:defer:withManager:] + 80
4 _macosx.cpython-37m-darwin.so 0x000000012ca04bc7 FigureManager_init + 327
5 Python 0x0000000124647050 wrap_init + 12
6 Python 0x000000012460e407 wrapperdescr_call + 337
7 Python 0x0000000124608668 _PyObject_FastCallKeywords + 365
8 Python 0x000000012469f3ad call_function + 746
9 Python 0x0000000124697f6f _PyEval_EvalFrameDefault + 7020
10 Python 0x0000000124608bdd function_code_fastcall + 112
11 Python 0x0000000124609561 _PyObject_Call_Prepend + 150
12 Python 0x0000000124646fbe slot_tp_init + 80
13 Python 0x0000000124643c85 type_call + 178
14 Python 0x0000000124608668 _PyObject_FastCallKeywords + 365
15 Python 0x000000012469f3ad call_function + 746
16 Python 0x0000000124697f6f _PyEval_EvalFrameDefault + 7020
17 Python 0x0000000124608bdd function_code_fastcall + 112
18 Python 0x000000012469f3b4 call_function + 753
19 Python 0x0000000124697f6f _PyEval_EvalFrameDefault + 7020
20 Python 0x000000012469fc5c _PyEval_EvalCodeWithName + 1857
21 Python 0x000000012460842a _PyFunction_FastCallDict + 441
22 Python 0x0000000124609561 _PyObject_Call_Prepend + 150
23 Python 0x0000000124608910 PyObject_Call + 136
24 Python 0x0000000124698286 _PyEval_EvalFrameDefault + 7811
25 Python 0x000000012469fc5c _PyEval_EvalCodeWithName + 1857
26 Python 0x00000001246087c7 _PyFunction_FastCallKeywords + 225
27 Python 0x000000012469f3b4 call_function + 753
28 Python 0x000000012469800d _PyEval_EvalFrameDefault + 7178
29 Python 0x0000000124608bdd function_code_fastcall + 112
30 Python 0x000000012469f3b4 call_function + 753
31 Python 0x000000012469800d _PyEval_EvalFrameDefault + 7178
32 Python 0x000000012469fc5c _PyEval_EvalCodeWithName + 1857
33 Python 0x00000001246087c7 _PyFunction_FastCallKeywords + 225
34 Python 0x000000012469f3b4 call_function + 753
35 Python 0x000000012469800d _PyEval_EvalFrameDefault + 7178
36 Python 0x000000012469fc5c _PyEval_EvalCodeWithName + 1857
37 Python 0x000000012460842a _PyFunction_FastCallDict + 441
38 jna2383965882915598410.tmp 0x000000010d842e74 ffi_call_unix64 + 76
39 ??? 0x000070000ee0e578 0x0 + 123145551930744
)
The Code is here :
(ns matplotlib-clj.core
(:require [libpython-clj.python :as py]
[tech.v2.datatype :as dtype]
[tech.libs.buffered-image :as bufimg]
[tech.v2.tensor :as dtt]
[clojure.java.io :as io]
[clojure.java.shell :as sh]))
(defn init-macox []
(alter-var-root
#'libpython-clj.jna.base/*python-library*
(constantly "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib"))
(py/initialize!))
(init-macox)
(def mfig (py/import-module "matplotlib.figure"))
(def magg (py/import-module "matplotlib.backends.backend_agg"))
(def np (py/import-module "numpy"))
(def plt (py/import-module "matplotlib.pyplot"))
(def x (py/call-attr np "linspace" 0 2 100))
;;(py/python-type x)
;;(py/get-attr x "shape")
(defn plot-it []
(py/call-attr-kw plt "plot" [x x] {"label" "linear"})
(py/call-attr-kw plt "plot" [x (py/call-attr x "__pow__" 2)] {"label" "quadratic"})
(py/call-attr-kw plt "plot" [x (py/call-attr x "__pow__" 3)] {"label" "cubic"})
(py/call-attr plt "xlabel" "x label")
(py/call-attr plt "ylabel" "y label")
(py/call-attr plt "title" "Simple Plot")
(py/call-attr plt "legend"))
(defn -main [& args]
(plot-it)
(py/call-attr plt "show"))
from libpython-clj.
I found a matplotlib issue related to this:
from libpython-clj.
Thanks @cnuernber, I use the WebAgg, it's work :-D
(def mplot (py/import-module "matplotlib"))
(py/call-attr mplot "use" "WebAgg")
from libpython-clj.
Nice work!!
Closing as I believe this is a matplotlib issue and not a libpython-clj issue.
from libpython-clj.
Related Issues (20)
- Cannot run the example in the tutorial in Cider with JDK 17 HOT 8
- process hanging in embeded mode on exception HOT 2
- from-import does not support "string"
- newbie: I get: `dir already refers to: #'clojure.repl/dir in namespace: user` HOT 2
- Newbie: Lein Clojure Windows Anaconda VSCode Cava REPL Returns (NoClassDefFoundError) HOT 5
- Create Python Module then Import Module and Call Function Inside Clojure? HOT 4
- Fix ubuntu version in dockerfiles HOT 6
- Consider releasing returned values from instance fns
- JDK-20 support HOT 3
- builtins/eval throws 'frame does not exist' HOT 2
- Unable to require libraries from within docker using conda HOT 6
- Failed to find a valid python library on MS-Windows with the official python distributions
- Extend CI coverage to all the mainstream architectures
- require-python missing functions with annotation HOT 3
- Make polyglot development easier by allow require-python to be path-informed HOT 1
- Data transformation pipelines? HOT 1
- NSWindow main thread error when trying to setup Gymnasium (openapi gym) HOT 5
- JVM crashes when requiring `libpython-clj2.require` on 64bit Raspberry Pi 4 HOT 1
- error of unhashable type HOT 15
- Ways to reduce probability of memory leaks? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libpython-clj.