* save plot in python babel
@ 2020-08-25 12:05 Jeremie Juste
2020-08-25 13:50 ` Jack Kamm
0 siblings, 1 reply; 3+ messages in thread
From: Jeremie Juste @ 2020-08-25 12:05 UTC (permalink / raw)
To: emacs-orgmode
Hello,
I've barely use python with org-mode and I would need some help with the
python setup. I somehow have some trouble saving python plots. Is this the right way
to do it?
#+begin_src python :results output file link :file myfig1.pdf :session *Python*
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
e_values = np.random.randn(100)
plt.plot(e_values)
#+end_src
In R things seems to be smoother.
#+begin_src R :results output graphics :file myfig1.pdf :session *R*
plot(1)
#+end_src
I tried to look around and noticed that the documentation regarding
python with org-mode is aging a bit and there are ob-* all over the
place. [1] ob-ipython does not seem to be maintained, [2] ein on top of ob-python
[1]: https://github.com/gregsexton/ob-ipython
[2]: https://github.com/millejoh/emacs-ipython-notebook
Any help will be appreciated. I'll be ready to improve the documentation of
org-babel python setup as soon as I'm more familiar with it myself.
Best regards,
Jeremie
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: save plot in python babel
2020-08-25 12:05 save plot in python babel Jeremie Juste
@ 2020-08-25 13:50 ` Jack Kamm
2020-08-26 21:02 ` Jeremie Juste
0 siblings, 1 reply; 3+ messages in thread
From: Jack Kamm @ 2020-08-25 13:50 UTC (permalink / raw)
To: Jeremie Juste, emacs-orgmode
Hi Jeremie,
> I tried to look around and noticed that the documentation regarding
> python with org-mode is aging a bit... Any help will be
> appreciated. I'll be ready to improve the documentation of org-babel
> python setup as soon as I'm more familiar with it myself.
Historically ob-python has been a bit broken, especially
sessions. Earlier this year, I started taking care of ob-python and
implemented some fixes [1], which will land in 9.4. When that's
released, I plan to update the outdated worg documentation [2].
> I've barely use python with org-mode and I would need some help with
> the python setup. I somehow have some trouble saving python plots. Is
> this the right way to do it?
This part of the documentation [2], at the bottom of the page, is still
up-to-date. Basically, you need to manually call plt.savefig(), then
return the filename.
> In R things seems to be smoother.
Yes, ob-R is in much better shape. In addition to plotting, returning
dataframes works (pandas DataFrames are not yet supported in
ob-python). I also much prefer the way ob-R returns lists as a column
vector instead of a row vector.
> there are ob-* all over the place. [1] ob-ipython does not seem to be
> maintained
For serious work these days, I'm using ob-jupyter [3], which works
really well. Scimax [4] also has a maintained fork of ob-ipython, though
I haven't tried it.
My goal is to make ob-python a serious alternative to these external
ob-* packages eventually. Here are some of the improvements I have in
mind:
- Improved plotting
- Support for pandas DataFrames and numpy Arrays
- Async session evaluation [5]
I've been delayed working on this as I've gotten very busy due to the
pandemic (I am a bioinformaticist working on SARS-CoV-2 sequencing). But
I'm hoping to make a bit of progress this week, as I'm on vacation and
unable to go outside due to the smoke from the California fires.
It's unclear to me if we're in a feature freeze, so I'm currently
pushing ob-python development to a separate branch [6], which I'll
cherry pick into master after the Org 9.4 release.
[1] https://orgmode.org/list/87pnfdo88v.fsf@gmail.com/
[2] https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html
[3] https://github.com/nnicandro/emacs-jupyter
[4] https://github.com/jkitchin/scimax
[5] https://github.com/jackkamm/ob-session-async
[6] https://code.orgmode.org/jackkamm/org-mode/src/python-develop
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: save plot in python babel
2020-08-25 13:50 ` Jack Kamm
@ 2020-08-26 21:02 ` Jeremie Juste
0 siblings, 0 replies; 3+ messages in thread
From: Jeremie Juste @ 2020-08-26 21:02 UTC (permalink / raw)
To: Jack Kamm; +Cc: emacs-orgmode
Hello Jack,
Many thanks for having taken the time to reply.
I'll definitely try ob-jupyter.
>
> My goal is to make ob-python a serious alternative to these external
> ob-* packages eventually. Here are some of the improvements I have in
> mind:
>
> - Improved plotting
> - Support for pandas DataFrames and numpy Arrays
> - Async session evaluation
yes these improvements would be great. My elisp skills are poor but I'll
be sure to give you feedback on these features.
> I've been delayed working on this as I've gotten very busy due to the
> pandemic (I am a bioinformaticist working on SARS-CoV-2 sequencing). But
> I'm hoping to make a bit of progress this week, as I'm on vacation and
> unable to go outside due to the smoke from the California fires.
>
> It's unclear to me if we're in a feature freeze, so I'm currently
> pushing ob-python development to a separate branch [6], which I'll
> cherry pick into master after the Org 9.4 release.
In your own time will be just fine. I've been only an enthusiastic user
of org-mode until now. I'll go through the manual again and I'll try to
give back what I can.
Stay safe,
Jeremie
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-26 21:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-25 12:05 save plot in python babel Jeremie Juste
2020-08-25 13:50 ` Jack Kamm
2020-08-26 21:02 ` Jeremie Juste
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).